<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>Forem: Codementor</title>
    <description>The latest articles on Forem by Codementor (@codementorio).</description>
    <link>https://forem.com/codementorio</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F139526%2F19992740-0422-4163-a7e3-7d20a9763342.png</url>
      <title>Forem: Codementor</title>
      <link>https://forem.com/codementorio</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/codementorio"/>
    <language>en</language>
    <item>
      <title>JavaScript Tutorial: Removing A Specific Element From An Array </title>
      <dc:creator>Codementor</dc:creator>
      <pubDate>Mon, 22 Feb 2021 04:50:22 +0000</pubDate>
      <link>https://forem.com/codementor/javascript-tutorial-removing-a-specific-element-from-an-array-1i73</link>
      <guid>https://forem.com/codementor/javascript-tutorial-removing-a-specific-element-from-an-array-1i73</guid>
      <description>&lt;p&gt;Have you ever been stuck trying to remove a specific item from an array? Imagine this: you are working on a shopping cart delete feature where you need to delete an item that the user doesn't want anymore. How would you go about using JavaScript's native array methods to remove that product ID from your shopping cart array? &lt;/p&gt;

&lt;p&gt;In this tutorial, we are going to look at how to remove a specific item from an array using JavaScript's native array methods: splice and filter.&lt;/p&gt;

&lt;p&gt;Watch the tutorial &lt;a href="http://www.youtube.com/watch?v=P69ItyngM-0"&gt;here&lt;/a&gt; or click on the image below to get started.&lt;br&gt;
&lt;a href="http://www.youtube.com/watch?v=P69ItyngM-0"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s---yNFwcmW--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://ucarecdn.com/fd968ed7-f894-4576-bbca-741e1def5a18/" alt="javascript video tutorial remove element from array"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  Method 1: Splice Method
&lt;/h2&gt;

&lt;p&gt;First off, what does the &lt;code&gt;splice&lt;/code&gt; method do?&lt;/p&gt;

&lt;p&gt;&lt;code&gt;Splice&lt;/code&gt; changes the contents of the array by removing, replacing, or adding new elements. The return value of the splice method is a new array containing the deleted elements.&lt;/p&gt;

&lt;p&gt;Let's take a look at what that means.&lt;/p&gt;
&lt;h3&gt;
  
  
  Splice mutates the original code
&lt;/h3&gt;

&lt;p&gt;Below is our array filled with fruits and a unicorn. To remove an item using splice, the first parameter is the index of the item we want to remove. The unicorn is in index 2. The second parameter determines how many items you want to delete, which will be 1.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const fruits = ["🥝", "🍓", "🦄", "🍊", "🍋"];

console.log(fruits.splice(2, 1)) // outputs: ["🦄"]

console.log(fruits); // output: ["🥝", "🍓", "🍊", "🍋"]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Notice how the output of the splice function returns the unicorn in an array, whereas &lt;code&gt;fruits&lt;/code&gt; array has changed to a unicorn-free fruit salad. &lt;/p&gt;

&lt;p&gt;Something to be extra careful about is &lt;strong&gt;when using splice, the original array is mutated&lt;/strong&gt;, meaning you are changing the original array.&lt;/p&gt;

&lt;h3&gt;
  
  
  But what if we don't want to mutate the original array?
&lt;/h3&gt;

&lt;p&gt;Let's look back at the &lt;code&gt;fruits&lt;/code&gt; array again. We don't know where the unicorn is. Here, we will be using the &lt;strong&gt;arrow function syntax in ES6&lt;/strong&gt;. We're going to copy the array, find the index, and splice it!&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const fruits = ["🥝", "🍓", "🦄", "🍊", "🍋", "🦄"];
const removeItem = (arr, item) =&amp;gt; {
  let newArray = [...arr];
  const index = newArray.findIndex((item) =&amp;gt; item === "🦄");
    if (index !== -1) {
     newArray.splice(index, 1);
      return newArray;
    }
};

console.log(removeItem(fruits, "🦄")); // output: ["🥝", "🍓", "🍊", "🍋", "🦄"]

console.log(fruits); // output: ["🥝", "🍓", "🦄", "🍊", "🍋", "🦄"]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;We will create a function that takes an array and item as parameters. &lt;/p&gt;

&lt;p&gt;First, to copy the array, we will use the spread operator. This way we won't mutate the data. &lt;/p&gt;

&lt;p&gt;Next, we will use the &lt;code&gt;findIndex&lt;/code&gt; method. This will find the &lt;strong&gt;first&lt;/strong&gt; element that satisfies the condition function. But if it returns -1, then it means there wasn't the element that fit the condition. &lt;/p&gt;

&lt;p&gt;To use the &lt;code&gt;findIndex&lt;/code&gt; method, we will type in the condition we want it to satisfy. &lt;/p&gt;

&lt;p&gt;Finally, to make sure we found the unicorn, we will check that the variable &lt;code&gt;index&lt;/code&gt; does not equal to -1, before splicing it to remove the item. &lt;/p&gt;

&lt;p&gt;Recall how the &lt;code&gt;splice&lt;/code&gt; method's first parameter is the index you want to change, and the second parameter is how many elements you want to remove in the array. Finally, We will need to return the variable &lt;code&gt;newArray&lt;/code&gt; to be able to get the output. &lt;/p&gt;

&lt;p&gt;So here we see that the output for the &lt;code&gt;removeItem&lt;/code&gt; function is an array of just fruits, and the original &lt;code&gt;fruits&lt;/code&gt; array remains unchanged.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;You might've noticed there was more than one unicorn in the above code.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Because &lt;code&gt;findIndex&lt;/code&gt; will only return the first element that satisfies the condition, we are still left with another unicorn.&lt;/p&gt;

&lt;p&gt;So if you need to handle duplicates, there's a more straightforward way we'll show you in the next method. &lt;/p&gt;

&lt;h2&gt;
  
  
  Method 2: Filter Method
&lt;/h2&gt;

&lt;p&gt;Unlike &lt;code&gt;splice&lt;/code&gt; which mutates the data, &lt;code&gt;filter&lt;/code&gt; creates &lt;strong&gt;a new array with elements that fit the condition&lt;/strong&gt;. We can also handle duplicates this way, as it checks against every single element in the array.&lt;/p&gt;

&lt;p&gt;The &lt;code&gt;filter&lt;/code&gt; method is very similar to &lt;code&gt;findIndex&lt;/code&gt;, in that the first parameter is a conditional function.&lt;/p&gt;

&lt;p&gt;When we output &lt;code&gt;newArray&lt;/code&gt;, notice how both of the unicorns are removed, and when we &lt;code&gt;console.log(fruits)&lt;/code&gt; again, it's still the original array .&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const fruits = ["🥝", "🍓", "🦄", "🍊", "🍋", "🦄"];
const newArray = fruits.filter((item) =&amp;gt; item !== "🦄");

console.log(newArray); // output: ["🥝", "🍓", "🍊", "🍋"]
console.log(fruits); // output: ["🥝", "🍓", "🦄", "🍊", "🍋", "🦄"];
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Key Takeaways
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Removing Duplicates
&lt;/h3&gt;

&lt;p&gt;Filter can directly handle duplicates, while splice needs extra help.&lt;/p&gt;

&lt;h3&gt;
  
  
  Data Mutation
&lt;/h3&gt;

&lt;p&gt;We need to be aware of the data mutation in these methods, for instance, &lt;code&gt;splice&lt;/code&gt; changes the original array, while &lt;code&gt;filter&lt;/code&gt; creates a brand new array.&lt;/p&gt;

&lt;p&gt;There are many ways to remove a specific item in an array. Splice and filter are some of the common ways using native JavaScripts array methods. &lt;/p&gt;

&lt;p&gt;We also shared the video tutorial on our Youtube channel &lt;a href="http://www.youtube.com/watch?v=P69ItyngM-0"&gt;here&lt;/a&gt;! &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Learn JavaScript by building projects on &lt;a href="https://www.codementor.io/javascript-projects"&gt;DevProjects&lt;/a&gt;&lt;/strong&gt;&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>Introducing DevProjects - Learn Programming by Building Projects</title>
      <dc:creator>Codementor</dc:creator>
      <pubDate>Fri, 18 Dec 2020 10:23:50 +0000</pubDate>
      <link>https://forem.com/codementor/introducing-devprojects-learn-programming-by-building-projects-282k</link>
      <guid>https://forem.com/codementor/introducing-devprojects-learn-programming-by-building-projects-282k</guid>
      <description>&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fzy3bwjnisqxgmk61qlb0.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fzy3bwjnisqxgmk61qlb0.png" alt="DevProjects by Codementor"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;“What are the best Python projects for beginners?”&lt;br&gt;&lt;br&gt;
“Where can I find JavaScript projects?”&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Chances are, if you’re learning programming, you’ve googled a variation of the above questions at one point or another. Through Codementor, we heard that a lot of our users did too. We asked ourselves: does it really have to be this hard? &lt;/p&gt;

&lt;p&gt;So we had many brainstorm sessions fueled by caffeine and sugar, and reached out to some mentors and users for feedback. We had one goal: to create a simple tool that anyone learning programming would find helpful.&lt;/p&gt;

&lt;p&gt;After much discussion, we understood two things. First, one of the hardest things about learning programming is transitioning from theory to real world code; and two: it’s more interesting to learn programming with actual projects.&lt;/p&gt;

&lt;h3&gt;
  
  
  Enter &lt;a href="https://www.codementor.io/projects?utm_campaign=alpaca01&amp;amp;utm_source=devto" rel="noopener noreferrer"&gt;DevProjects&lt;/a&gt;
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fgt65ogs59eizx83ln2kx.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fgt65ogs59eizx83ln2kx.png" alt="DevProjects by Codementor"&gt;&lt;/a&gt;&lt;br&gt;
Or, as our team affectionately calls it, Project Alpaca (because alpacas are social and inquisitive animals).&lt;/p&gt;

&lt;p&gt;We intentionally designed &lt;a href="https://www.codementor.io/projects?utm_campaign=alpaca01&amp;amp;utm_source=devto" rel="noopener noreferrer"&gt;DevProjects&lt;/a&gt; to help you seamlessly transition from “hello world” to real world programming. We also aimed to make this process easy, interesting, interactive, and best of all, fun.&lt;/p&gt;

&lt;p&gt;DevProjects is a community where everyone learning programming has free and easy access to projects for learners. Users can learn through discussing the project with peers and mentors, as well as sharing and receiving feedback on their code. &lt;/p&gt;

&lt;h3&gt;
  
  
  What projects are on DevProjects?
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2F1pxnpoqccdavvwn56zni.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2F1pxnpoqccdavvwn56zni.png" alt="DevProjects by Codementor- project-based learn programming"&gt;&lt;/a&gt;&lt;br&gt;
DevProjects has a growing collection of curated projects for web development, mobile apps, and automation/tools. Project difficulties range from very beginner to the more advanced. &lt;/p&gt;

&lt;p&gt;We worked with mentors and senior developers to design projects that would help you bridge the gap between theory and practice. Not only is each project specifically constructed to address problems you might face when applying your skills in the real world, the projects provide context and are limited in scope. This gives you a sense of how developers work with a product team or as a freelancer. &lt;/p&gt;

&lt;h3&gt;
  
  
  Other than the curated projects, why should I use DevProjects?
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2F2en1w20brozrrb6m69hr.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2F2en1w20brozrrb6m69hr.png" alt="DevProjects by Codementor - learn programming by building projects"&gt;&lt;/a&gt;&lt;br&gt;
Learning programming is hard enough, especially when you’re stuck with a project and don’t know where to start untangling the mess.&lt;/p&gt;

&lt;p&gt;But there’s no need to do it alone.&lt;/p&gt;

&lt;p&gt;DevProjects is designed to be an open and interactive community. Users are encouraged to discuss the best way to approach a project with peers and mentors, and learn how to see a project from different perspectives. You can also share your code, receive feedback, as well as get code reviews and pointers on how to improve. &lt;/p&gt;

&lt;p&gt;We designed &lt;a href="https://www.codementor.io/projects?utm_campaign=alpaca02&amp;amp;utm_source=devto" rel="noopener noreferrer"&gt;DevProjects&lt;/a&gt; for you and others that are learning programming. Since learning programming is already a difficult task in itself, we wanted to help shrink the gap between theory and real world application. We hope that DevProjects will help you bridge that gap, and pave the way to your programming journey success. &lt;/p&gt;

&lt;p&gt;Check out &lt;a href="https://www.codementor.io/projects?utm_campaign=alpaca02&amp;amp;utm_source=devto" rel="noopener noreferrer"&gt;DevProjects&lt;/a&gt; if you haven’t already, and we’d love to hear what you think! &lt;/p&gt;

</description>
      <category>webdev</category>
      <category>tutorial</category>
      <category>codenewbie</category>
      <category>showdev</category>
    </item>
    <item>
      <title>Learning Django Through Problem-Solving: How A Lawyer Built His Side Project</title>
      <dc:creator>Codementor</dc:creator>
      <pubDate>Wed, 02 Sep 2020 09:20:18 +0000</pubDate>
      <link>https://forem.com/codementor/learning-django-through-problem-solving-how-a-lawyer-built-his-side-project-4b1l</link>
      <guid>https://forem.com/codementor/learning-django-through-problem-solving-how-a-lawyer-built-his-side-project-4b1l</guid>
      <description>&lt;blockquote&gt;
&lt;p&gt;“I’m not looking to be a programmer. I just want to build State of K, but at this point, I’ve probably already learned every topic in Django.” &lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Ingram, a full-time lawyer and creator of &lt;a href="http://stateofk.com/"&gt;State of K&lt;/a&gt;, the Q-and-A website where users can answer their own questions based on academic studies, started his programming journey with a very clear goal and a very vague idea of how. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--rht82shP--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://ucarecdn.com/82eb70ff-07f3-478a-9af8-ece5f08ffa29/" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--rht82shP--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://ucarecdn.com/82eb70ff-07f3-478a-9af8-ece5f08ffa29/" alt="StateofK.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;“For many years, I had the idea of a site that I wanted to exist,” Ingram explained, “There are certain types of questions — empirical questions — where the best available answer comes from published studies, rather than someone’s opinion. But there are too many obstacles to understanding what those studies say. I wanted to solve that problem.” &lt;/p&gt;

&lt;p&gt;Under normal circumstances, someone with barely any programming knowledge would choose to hire an expert developer to build their product. “I would liken it to a work of art,” Ingram explained, “You can’t commission an artist if you don’t know yet what you want the drawing to look like.” He went on to share that as he didn’t have a clear image of how the question-answer website would work, he wanted the freedom to be able to play around with the code. And as he had no idea what he would ask the developer to do, Ingram figured it would be easier to control the budget by building it himself. &lt;/p&gt;

&lt;p&gt;So only equipped with the basic HTML and CSS learned at the turn of the century, he tried creating a website mockup by making a table with HTML “Because that’s what people did in 2001.” It got the job done, but he also quickly realized that his knowledge was outdated, and certainly not enough to bring the idea he had in his head to life.&lt;/p&gt;

&lt;p&gt;After lots of research, Ingram theorized a “very complicated way” to build the website and set out to find a mentor or senior developer that could give him feedback. “The first person I met on &lt;a href="http://www.codementor.io/?utm_source=devto&amp;amp;utm_campaign=outreach"&gt;Codementor&lt;/a&gt; told me my implementation plan was totally wrong,” he laughed. Luckily, it wasn’t all in vain as the mentor pointed him in the right direction: to learn Django. &lt;/p&gt;

&lt;p&gt;And so he did. But as a full-time lawyer with limited free time, Ingram needed a way to learn code that could fit into his busy schedule. But traditional teaching methods weren’t a good fit: “With bootcamps, you need to be physically on site or adhere to their teaching schedule.” Instead, he started teaching himself by buying a book, watching Youtube videos, and  purchasing several Udemy courses. &lt;/p&gt;

&lt;p&gt;After a while, he realized he was making decisions that would have a butterfly effect on future decisions. He figured he could either continue puzzling together advice from YouTube videos, or work with a mentor that knew what they were doing and could help him make better decisions. &lt;/p&gt;

&lt;p&gt;He chose the latter. &lt;/p&gt;

&lt;p&gt;Ingram chatted with a couple of mentors and eventually found &lt;a href="https://www.codementor.io/@jessamynsmith?utm_source=devto&amp;amp;utm_campaign=outreach"&gt;Jessamyn&lt;/a&gt;, a mentor he’s been consistently working with for years now. They started out working together a couple of times a week before increasing it to multiple times a week as his project (and budget) increased. &lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;One surprising takeaway was how helpful working with a mentor was for learning the most basic things. &lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;“It was like my 10th session, when Jessamyn asked off-handedly where I was saving my code,” he shared. And like most non-technical people, Ingram saved the project on his laptop. In that session, he learned about Git, how to use it, and how a programmer would actually run a project. “Of course, there are YouTube videos on how to use Git, but if you don’t know that it exists, you wouldn’t know to search for it in the first place.” &lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--SHwq2ek0--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://ucarecdn.com/4eb41a34-5f68-4aa2-96f7-7bb2d5926852/" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--SHwq2ek0--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://ucarecdn.com/4eb41a34-5f68-4aa2-96f7-7bb2d5926852/" alt="State of K quote-Codementor.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;“I’m not interested in becoming a developer. I’m just interested in building a specific project,” he emphasized when we talked about his learning journey. With traditional learning models, the foundation building, while critical, did not fit into Ingram’s schedule. “The problem with the foundation learning model for me is that I don’t understand why the content will be useful until many months later by which time I’ve forgotten the lesson and have to relearn it. ” &lt;/p&gt;

&lt;p&gt;He uses a goal-oriented approach when learning. “I usually know what I want to create,” Ingram said about his learning process. He spends time going through online resources and documentation — “the free official documentation for Python and Django have been the most useful” — before coming up with an implementation plan he shares with the mentor. “I try to do as much as I can on my own, and get Jessamyn’s approval early on,” he shared, “It’s an iterative process. Usually, if I’ve put enough thought into it beforehand, the concept works out the first time, but sometimes considerations that I never even thought of pop up once I start implementing."&lt;/p&gt;

&lt;p&gt;However, with a demanding full-time job, there are days when he tries to shortcut the learning process: “It’s usually after I’ve pulled a couple of all nighters at work, or I reasonably believe that I won’t encounter a specific issue again.” During these sessions, he’ll learn by watching the mentor code and ask questions as she goes, which is much less demanding. “But I have to say, in almost every case, I end up encountering the problem again and have to spend more money and time to master what she did,” he said, “It usually pays to just pay attention and learn it properly the first time.” &lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--3ErrjxzC--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://ucarecdn.com/6c465708-4022-4c74-b1a2-7f3ee79ef76b/" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--3ErrjxzC--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://ucarecdn.com/6c465708-4022-4c74-b1a2-7f3ee79ef76b/" alt="Codementor Learn Django.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;It’s been four years since Ingram started on his programming journey, and State of K is steadily growing its user base. While his learning process can be described as “problem solving”, at this point, he’s “probably already learned every topic in the Django library and could apply that knowledge to other projects.” This has been echoed by his mentor, Jessamyn: “Ingram showed incredible growth as a developer over the several years I was actively mentoring him. He went from a novice to being able to develop quite complex features.”&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;"Have I learned Django more slowly than someone else? Definitely. But I've also done it while working a full-time job, which I think is also pretty great."&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;em&gt;This post was originally published on &lt;a href="https://www.codementor.io/blog/django-lawyer-a5j3og2tox?utm_source=devto&amp;amp;utm_campaign=outreach"&gt;Codementor&lt;/a&gt;.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>learnprogramming</category>
      <category>django</category>
      <category>selftaught</category>
      <category>developer</category>
    </item>
    <item>
      <title>[Dev Journey] He's Using His National Athlete Experience to Build A Language Learning App </title>
      <dc:creator>Codementor</dc:creator>
      <pubDate>Wed, 12 Aug 2020 03:42:29 +0000</pubDate>
      <link>https://forem.com/codementor/dev-journey-he-s-using-his-national-athlete-experience-to-build-a-language-learning-app-2dgi</link>
      <guid>https://forem.com/codementor/dev-journey-he-s-using-his-national-athlete-experience-to-build-a-language-learning-app-2dgi</guid>
      <description>&lt;p&gt;&lt;em&gt;In this series, we're shining the spotlight on members of the &lt;a href="https://www.codementor.io?utm_source=devto"&gt;Codementor&lt;/a&gt; community. They share their journey to becoming a developer — the highs, the lows, and the inbetweens. This story was written by Mitchell Gould, a national athlete turned tech entrepreneur.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;When I was 10 years old, my father came into my room and asked "how would you like to climb Kilimanjaro?" I, of course, jumped at the idea, not having the faintest idea what a Kilimanjaro was or where it was located. My father never mentioned the topic again. But the seed was planted and if you keep reading, you will find out how IT enabled me to conquer that mountain.&lt;/p&gt;

&lt;p&gt;I have been asked to write about how my varied background in a multitude of careers has helped me at being an entrepreneur. But after developing an aversion to labels at a very young age, I don't really think of  myself as an entrepreneur. &lt;/p&gt;

&lt;p&gt;My family moved from New York to Toronto when I was very young. I wanted to fit in, so I decided I would become a hockey player. This was Canada after all. But as luck would have it, my mother watched a hockey match shortly before I asked. And jaded by the blood and violence of the game, she, in classic mother fashion, replied with four words: over my dead body.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--fBV6DoTd--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://ucarecdn.com/fe473565-a4dc-4cc0-bfe9-9a180fe0284f/" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--fBV6DoTd--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://ucarecdn.com/fe473565-a4dc-4cc0-bfe9-9a180fe0284f/" alt="Mitchell Gould Codementor story 1.jpg"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Instead, I was enrolled in figure skating and conned into believing that all great hockey players took figure skating lessons. When the kids at school found out, I was teased, ridiculed, and frequently beaten. I learned that I had to hide risky labels if I wanted to be safe. By ignoring the labels, I found myself focusing on the skills and practices associated with them.&lt;/p&gt;

&lt;p&gt;This rejection of labels has had the positive side effect of helping me to be less judgmental of myself and others. I also believe it has freed me to pursue a multitude of careers in completely unrelated fields such as (in no particular order): &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;international competitor on Canada's National Figure Skating Team &lt;/li&gt;
&lt;li&gt;brain researcher associated with the  Canadian Aerospace Medical Research Unit &lt;/li&gt;
&lt;li&gt;a Cordon Bleu certified chef at the renowned Olive and Gourmando Cafe&lt;/li&gt;
&lt;li&gt;write and produce movies, one of which won the National Drama Prize &lt;/li&gt;
&lt;li&gt;CELTA certified teacher at 3 universities in Chiang Mai, Thailand &lt;/li&gt;
&lt;li&gt;graduate from the Information Technology Institute and build my own IT projects&lt;/li&gt;
&lt;li&gt;buddhist monk in Cambodia as part of a project to restart Buddhism in rural communities.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;What I find most fascinating is how each of these careers surprised me with challenges to develop myself, gain new skills I never would have imagined, and how these skills translated from one career to the other.&lt;/p&gt;

&lt;p&gt;For example, as a chef, you would expect to spend your time cooking things like Veloutés, Cassoulet, or Confit de canard. But I actually spent a great deal of my time solving problems. Like the time our food supplier missed our delivery, and I had to source and balance five boxes of portobello mushrooms while riding a bike in a Canadian snowstorm. Or when the water was accidentally left running in the espresso machine overnight and we had to deal with the espresso flood the next morning.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--FgvDKRkw--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://ucarecdn.com/6b2e9d7a-3959-4f3a-ae0b-65175d3b624d/" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--FgvDKRkw--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://ucarecdn.com/6b2e9d7a-3959-4f3a-ae0b-65175d3b624d/" alt="Mitchell Gould Codementor ProvenWord.jpeg"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;As a skater, I practiced how to throw my weight into the air to achieve enough momentum to complete 2.5 rotations and land safely. I had to overcome fear and have complete trust in myself. This turned into a life philosophy. I never would have predicted that doing a double axle would help me to confidently launch myself into so many different careers and projects. &lt;/p&gt;

&lt;p&gt;My current project, code named 'ProvenWord', is a direct consequence of teaching English in Thailand for 3 years. I witnessed firsthand, the difficulty of learning to write in English, something I took for granted as a native English speaker. I partnered with a friend who has over 20 years of proofreading experience, to develop an application that helps non-native English learners improve their writing. &lt;/p&gt;

&lt;p&gt;In competitive ice skating judges would immediately evaluate your performance and hold up a score from 0 to 10. I found that this kind of direct and immediate feedback to be very powerful (and,  at times, painful). ProvenWord draws significantly from this experience. Our system instantly  evaluates a client's writing, categorizes their errors (e.g. verb, punctuation, capitalization etc.), and presents the results in a visually stunning graphical interface. Clients gain a clear picture of where they need to focus to improve their writing are are provided with interactive learning tools designed for each error category. &lt;/p&gt;

&lt;p&gt;Of all the careers, jobs, and projects that I have been a part of, ProvenWord has &lt;em&gt;proven&lt;/em&gt; to be the most challenging. We literally had no money when we started this project. My skills in IT were quite limited and/or outdated. The scope of the project kept growing and went well beyond my pay grade. But this sounded like an awesome challenge to me, so I decided to up my IT abilities, and for that I needed help. A lot of help. &lt;/p&gt;

&lt;p&gt;It took me quite a while to find the resources, learning platforms, and coding legends I wanted to learn from. I'm also a very slow learner, so I found myself taking many courses on the same topic from different teachers, exposing me to an array of coding styles and ideologies. &lt;/p&gt;

&lt;p&gt;While courses and resources gave me a solid foundation, nothing was as powerful or effective as working with a mentor. I have to give a shout out to the people at &lt;a href="https://www.codementor.io?utm_source=devto"&gt;Codementor&lt;/a&gt; for building this platform with access to so many incredible developers. That's not to say I found the right mentors the first time. It took me a few sessions until I connected with mentors with a good balance of patience, pedagogy, and expertise that resonated with me.  &lt;/p&gt;

&lt;p&gt;I initially worked with mentors to fix specific bugs, but more often than not, the mentor would point out the larger problem that needed to be fixed. Mentoring sessions went from 'bug fixes' to developing high level strategies and best practices that would take my coding skills to a whole new level. I learned how to take a step back to think about the problem, how the structure could be adjusted, and more importantly, I learned how to solve the problem when it came around next time. I remember there was one time I had to scrap my entire code after a mentoring session. Rather than band-aiding the existing code, my mentor asked what I was trying to achieve. He then took a step back and taught me how to look at all the other ways of writing better code with the same function. I finished that mentoring session feeling like Keanu Reaves in The Matrix, like I was plugged in and getting an upgrade. I was excited, fired up, and motivated  to go back to work and apply this new found knowledge. &lt;/p&gt;

&lt;p&gt;That's the feeling I get after every fruitful mentoring session. Finding the right mentor allowed me to up my game and skillset. They opened my mind and taught me things I didn't even request in the initial communication. Working with the right mentor can be highly motivating, but that doesn't mean I didn't prepare beforehand. I learned that to get the most out of mentoring, I needed to be clear about what I wanted from each session. This forced me to think deeply about each problem and document it precisely. Sometimes this preparation was enough for me to solve the problem myself. Other times, the document with code samples, pseudo code, and other information helped my mentor prepare for our session, and would be able to more efficiently, come up with a strategy or solution. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--0XhGr8mW--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://ucarecdn.com/7baea065-b22c-4d9a-a0a8-5ea4643815d9/" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--0XhGr8mW--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://ucarecdn.com/7baea065-b22c-4d9a-a0a8-5ea4643815d9/" alt="Mitchell Gould Codementor Kilimanjaro.jpeg"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now back to the Kilimanjaro story.&lt;/p&gt;

&lt;p&gt;I was attending the Information Technology Institute in Ottawa, Canada when I met Yvonne. She was a refuge from Rwanda and a truly brilliant woman. We quickly became close friends and helped each other get through the grueling course load.&lt;/p&gt;

&lt;p&gt;We graduated just after the 2000 dotcom bubble burst and there were no jobs for freshly graduated IT students. With no choice and nothing to lose, we setup shop in a room of my Montreal apartment and built websites, designed business cards, fliers, and did whatever we could to get by.&lt;/p&gt;

&lt;p&gt;One day Yvonne walked into the office and told me she was going to Nairobi, Kenya to see her family. A quick Google search showed me where Nairobi was: 4 hours north of Arusha, Tanzania - the staging city for climbing Kilimanjaro. Taking this as a sign from the universe, I contacted my friend, Adam, who was then working somewhere in Nigeria. Coincidentally he wanted to quit his job and was up for an adventure. So I booked a flight and fulfilled my childhood dream, only without my dad (he was proud of me anyway).&lt;/p&gt;

</description>
      <category>developer</category>
      <category>career</category>
      <category>motivation</category>
      <category>learning</category>
    </item>
    <item>
      <title>Remote Career Summit 2020 (June 25th)</title>
      <dc:creator>Codementor</dc:creator>
      <pubDate>Mon, 22 Jun 2020 05:35:40 +0000</pubDate>
      <link>https://forem.com/codementor/remote-career-summit-2020-june-25th-339j</link>
      <guid>https://forem.com/codementor/remote-career-summit-2020-june-25th-339j</guid>
      <description>&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--VxUtRglP--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/k95lj6g4tlb7owvnlzjg.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--VxUtRglP--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/k95lj6g4tlb7owvnlzjg.png" alt="Remote Career Summit 2020"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;We're holding the &lt;a href="https://bit.ly/3fNTrf4"&gt;Remote Career Summit 2020&lt;/a&gt; on June 25!&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Don't miss this opportunity to hear from the leading companies in remote work, attend workshops, and possibly even find you next remote role at the career expo.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;It's free to attend (&lt;a href="https://bit.ly/2YQzrlm"&gt;sign up here&lt;/a&gt;). Check out the information below.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;We’re still adding new information and speakers — watch this space!&lt;/em&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Introduction
&lt;/h2&gt;

&lt;p&gt;Here at Arc, we love remote work — our day job is helping expert remote developers find great projects and organizations, after all. So when the COVID-19 pandemic forced a lot of people and companies to suddenly &lt;em&gt;go remote&lt;/em&gt;, and the economic outlook began to look a bit shaky, we wondered how we could help. Could we help people “do remote better” &lt;em&gt;and&lt;/em&gt; help people connect with job opportunities?&lt;/p&gt;

&lt;p&gt;The answer we stumbled upon over a few team video chats was this: holding the world’s biggest virtual Remote Career Summit. This day-long event is part remote work conference, part virtual job fair.&lt;/p&gt;

&lt;p&gt;We’re collaborating with some of the world’s top remote work experts and companies to bring you this unique opportunity to launch — or grow — your remote career. The best bit: there are still more talks to be announced 🎉&lt;/p&gt;

&lt;p&gt;If this sounds as exciting to you as it does to us, welcome aboard!&lt;/p&gt;

&lt;h2&gt;
  
  
  Two-In-One Event
&lt;/h2&gt;

&lt;p&gt;The Remote Career Summit 2020 is a two-in-one event, comprising a &lt;strong&gt;Career Conference&lt;/strong&gt; and a &lt;strong&gt;Job Fair&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;Whether you’re a developer, a designer, or a marketer, there’s something for everyone. We’re collaborating with some of the biggest names in the tech and remote working worlds to bring you insights. You’ll come away with new knowledge about:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Landing your first remote job&lt;/li&gt;
&lt;li&gt;Online collaboration best practices, and&lt;/li&gt;
&lt;li&gt;How to stand out as a candidate in the remote hiring process.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Intrigued? Check out the details below.&lt;/p&gt;

&lt;h2&gt;
  
  
  Career Conference Speaker Schedule — Main Stage
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Arc — State of Remote Jobs
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;9:00-9:20am (PT)&lt;/strong&gt;&lt;br&gt;
In this opening keynote, Arc &amp;amp; Codementor Founder/CEO Weiting Liu walks us through the state of remote jobs in 2020, including key stats and insights.&lt;/p&gt;

&lt;h3&gt;
  
  
  Automattic x Buffer x GitLab — Under the Hood: Working at the World’s Biggest All-Remote Companies
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;9:30-10:30am (PT)&lt;/strong&gt;&lt;br&gt;
Join three of the biggest brands in remote as they have a conversation with Laurel Farrer of Distribute Consulting. You’ll learn what makes these companies tick — and what they look for when hiring. From remote processes to collaboration and cultural fit, don’t miss this opportunity to hear and compare remote expertise.&lt;/p&gt;

&lt;h3&gt;
  
  
  Doist x MURAL x Virtual Work Insider — How to Get Hired for Remote Work
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;10:35-11:15am (PT)&lt;/strong&gt;&lt;br&gt;
From the key skills you need to succeed at remote work and a look into the hiring process of remote companies, to tips on how to capture a recruiter's attention and the number one piece of advice job-seekers need to hear right now... don't miss this chance to hear how to stand out as a candidate.&lt;/p&gt;

&lt;h3&gt;
  
  
  DHH (Basecamp &amp;amp; HEY) &amp;amp; Tammy Bjelland (Workplaceless) — Building a Calm and Ethical Workplace
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;11:30am-12:10pm (PT)&lt;/strong&gt;&lt;br&gt;
This fireside chat promises wide-ranging insights on remote work management, integrating remote work into a previously-colocated company, and why trust and great writing skills help unlock calm productivity.&lt;/p&gt;

&lt;h3&gt;
  
  
  Roundtable — Diversity, Inclusion, and Remote Work
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;12:20-1:10pm (PT)&lt;/strong&gt;&lt;br&gt;
Join speakers from Career Karma, Under Armour, Workfrom, and Cota Capital as they discuss diversity and inclusion, and whether or not embracing remote work is a way to create more inclusive workplaces.&lt;/p&gt;

&lt;h3&gt;
  
  
  Dribbble x Creative Market — Management, Scaling, &amp;amp; Remote Culture: Dribbble’s Balancing Act
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;1:15-1:50pm (PT)&lt;/strong&gt;&lt;br&gt;
So your company’s fully-remote. Now what? Learn from the CEOs of Dribbble and Creative Market as they discuss building and scaling remote teams, preserving and refocusing culture, and management dos and don’ts.&lt;/p&gt;

&lt;h3&gt;
  
  
  Roundtable — Nail Your Next Interview: Tips for Job-Seeking Developers
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;2:00-3:00pm (PT)&lt;/strong&gt;&lt;br&gt;
Join speakers from Shopify, Zapier, and Help Scout for this must-listen session on getting hired as a remote developer. Whether it's technical interviewing, remote hiring processes, developer portfolio preparation, or self-improvement tips, it's all here.&lt;/p&gt;

&lt;h3&gt;
  
  
  Roundtable — How Design Teams Successfully Collaborate and Hire Remotely
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;3:10-4:10pm (PT)&lt;/strong&gt;&lt;br&gt;
How do remote design teams make decisions? What tools are they using? How do they hire? Learn the answers to these questions — and more — during this session with speakers from Microsoft, Dialpad, Coinbase, UnitedHealthcare, and Litmus.&lt;/p&gt;

&lt;h3&gt;
  
  
  Rand Fishkin (SparkToro) — Get Hired in Marketing... in 2020
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;4:15-4:45pm (PT)&lt;/strong&gt;&lt;br&gt;
What skills do marketers need in 2020? In this data-driven presentation, SparkToro CEO Rand Fishkin breaks down the must-haves and must-knows for current marketing job-seekers.&lt;/p&gt;

&lt;h3&gt;
  
  
  Ryan Choi (Y Combinator) — Why Work at a Startup
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;4:50-5:30pm (PT)&lt;/strong&gt;&lt;br&gt;
Thinking about working at a startup? What should you know? How can you assess a startup, and whether it's a good fit for you and your career? Y Combinator's Ryan Choi gives an insider's look into why you should — or shouldn't — work at a startup.&lt;/p&gt;

&lt;h3&gt;
  
  
  Arc — Closing
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;5:30-5:40pm (PT)&lt;/strong&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Talks, Q&amp;amp;As, and Workshops
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Fernando Angulo (SEMrush) — Building Your Online Presence as a Marketer
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;12:00-12:30pm (PT)&lt;/strong&gt;&lt;br&gt;
SEO, influencers, and personal branding. How can you tie it all together to build your online presence as a marketer? Join SEMrush's Head of Communications to find out!&lt;/p&gt;

&lt;h3&gt;
  
  
  Caro Griffin (Skillcrush) — How to Land Your First Remote Job in Tech
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;3:30-4:00pm (PT)&lt;/strong&gt;&lt;br&gt;
So you want a remote job. That's great! But... where do you start? Skillcrush's Caro Griffin is here to help, with this presentation on how to find remote jobs.&lt;/p&gt;

&lt;h3&gt;
  
  
  Vinayak Ranade (Drafted) — How to Leverage Your Network
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;4:00-4:30pm (PT)&lt;/strong&gt;&lt;br&gt;
Spoiler alert: networking still matters, even for remote jobs. Get actionable tips on how to leverage your network from the CEO of Drafted.&lt;/p&gt;

&lt;h2&gt;
  
  
  Virtual Job Fair
&lt;/h2&gt;

&lt;p&gt;The virtual Job Fair will be running in parallel to the Career Conference talks, and available at all times.&lt;/p&gt;

&lt;p&gt;At the &lt;strong&gt;Job Fair&lt;/strong&gt;, you can:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Discover companies still hiring in the Employer Expo&lt;/li&gt;
&lt;li&gt;Chat with company reps to ask questions and learn more&lt;/li&gt;
&lt;li&gt;Connect with other professionals and grow your network&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  What Are You Waiting For?
&lt;/h2&gt;

&lt;p&gt;If you haven’t signed up for your free attendee ticket yet, now’s the time! &lt;a href="https://bit.ly/2YQzrlm"&gt;Grab your ticket here&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Are you an employer looking to have your brand represented at the job fair? &lt;a href="https://arcdotdev.typeform.com/to/N2o4TS#source=devto"&gt;Click here&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Let us know in the comments below if you have any questions.&lt;/p&gt;

&lt;p&gt;Look forward to seeing you there!&lt;/p&gt;

</description>
      <category>career</category>
      <category>learning</category>
      <category>remote</category>
      <category>interview</category>
    </item>
    <item>
      <title>10 Performance Optimization Techniques for React Apps</title>
      <dc:creator>Codementor</dc:creator>
      <pubDate>Thu, 12 Mar 2020 09:56:03 +0000</pubDate>
      <link>https://forem.com/codementor/10-performance-optimization-techniques-for-react-apps-2f9b</link>
      <guid>https://forem.com/codementor/10-performance-optimization-techniques-for-react-apps-2f9b</guid>
      <description>&lt;p&gt;Internally, React uses several clever techniques to minimize the number of costly DOM operations required to update the UI. While this will lead to a faster user interface without specifically optimizing for performance for many cases, there are ways where you can still speed up your React application. This post will go over some useful techniques you can use to improve your React code. &lt;/p&gt;

&lt;h2&gt;
  
  
  1. Using Immutable Data Structures
&lt;/h2&gt;

&lt;p&gt;Data immutability is not an architecture or design pattern, it’s an opinionated way of writing code. This forces you to think about how you structure your application data flow. In my opinion, data immutability is a practice that revolves around a strict unidirectional data flow.   &lt;/p&gt;

&lt;p&gt;Data immutability, which comes from the functional programming world, can be applied to the design of front-end apps. It can have many benefits, such as:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Zero side-effects; &lt;/li&gt;
&lt;li&gt;Immutable data objects are simpler to create, test, and use;&lt;/li&gt;
&lt;li&gt;Helps prevent temporal coupling;&lt;/li&gt;
&lt;li&gt;Easier to track changes.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;In the React landscape, we use the notion of &lt;code&gt;Component&lt;/code&gt; to maintain the internal state of components, and changes to the state can cause the component to re-render.&lt;/p&gt;

&lt;p&gt;React builds and maintains an internal representation of the rendered UI (Virtual DOM). When a component’s props or state changes, React compares the newly returned element with the previously rendered one. When the two are not equal, React will update the DOM. Therefore, we have to be careful when changing the state. &lt;/p&gt;

&lt;p&gt;Let’s consider a User List Component:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nx"&gt;state&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
       &lt;span class="na"&gt;users&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[]&lt;/span&gt;
   &lt;span class="p"&gt;}&lt;/span&gt;

   &lt;span class="nx"&gt;addNewUser&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
       &lt;span class="cm"&gt;/**
        *  OfCourse not correct way to insert
        *  new user in user list
        */&lt;/span&gt;
       &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;users&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;state&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;users&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
       &lt;span class="nx"&gt;users&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;push&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
           &lt;span class="na"&gt;userName&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;robin&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
           &lt;span class="na"&gt;email&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;email@email.com&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;
       &lt;span class="p"&gt;});&lt;/span&gt;
       &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;setState&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;&lt;span class="na"&gt;users&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;users&lt;/span&gt;&lt;span class="p"&gt;});&lt;/span&gt;
   &lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The concern here is that we are pushing new users onto the variable &lt;code&gt;users&lt;/code&gt;, which is a reference to &lt;code&gt;this.state.users&lt;/code&gt;. &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Pro Tip&lt;/strong&gt;: React state should be treated as immutable. We should never mutate &lt;code&gt;this.state&lt;/code&gt; directly, as calling &lt;code&gt;setState()&lt;/code&gt; afterward may replace the mutation you made.&lt;/p&gt;

&lt;p&gt;So what’s wrong with mutating &lt;code&gt;state&lt;/code&gt; directly? Let’s say we overwrite &lt;code&gt;shouldComponentUpdate&lt;/code&gt;  and are checking &lt;code&gt;nextState&lt;/code&gt; against &lt;code&gt;this.state&lt;/code&gt; to make sure that we only re-render components when changes happen in the state.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt; &lt;span class="nx"&gt;shouldComponentUpdate&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;nextProps&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;nextState&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;state&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;users&lt;/span&gt; &lt;span class="o"&gt;!==&lt;/span&gt; &lt;span class="nx"&gt;nextState&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;users&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="kc"&gt;false&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Even if changes happen in the user's array, React won’t re-render the UI as it’s the same reference. &lt;/p&gt;

&lt;p&gt;The easiest way to avoid this kind of problem is to avoid mutating props or state. So the&lt;br&gt;
&lt;code&gt;addNewUser&lt;/code&gt;  method could be rewritten using &lt;code&gt;concat&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;   &lt;span class="nx"&gt;addNewUser&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
       &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;setState&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;state&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;({&lt;/span&gt;
         &lt;span class="na"&gt;users&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;state&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;users&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;concat&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
           &lt;span class="na"&gt;timeStamp&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nb"&gt;Date&lt;/span&gt;&lt;span class="p"&gt;(),&lt;/span&gt;
           &lt;span class="na"&gt;userName&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;robin&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
           &lt;span class="na"&gt;email&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;email@email.com&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;
         &lt;span class="p"&gt;})&lt;/span&gt;
       &lt;span class="p"&gt;}));&lt;/span&gt;
   &lt;span class="p"&gt;};&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;For handling changes to state or props in React components, we can consider the following immutable approaches:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;For arrays: use &lt;code&gt;[].concat&lt;/code&gt; or es6 &lt;code&gt;[ ...params]&lt;/code&gt; &lt;/li&gt;
&lt;li&gt;For objects: use &lt;code&gt;Object.assign({}, ...)&lt;/code&gt; or es6 &lt;code&gt;{...params}&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;These two methods go a long way when introducing immutability to your code base.&lt;/p&gt;

&lt;p&gt;But it’s better to use an optimized library which provides a set of immutable data structures. Here are some of the libraries you can use: &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt; &lt;a href="https://github.com/kolodny/immutability-helper"&gt;Immutability Helper&lt;/a&gt;: This is a good library when it’s comes to mutating a data copy without changing the source.&lt;/li&gt;
&lt;li&gt; &lt;a href="https://facebook.github.io/immutable-js/"&gt;Immutable.js&lt;/a&gt;: This is my favorite library as it provides a lot of persistent immutable data structures, including: &lt;a href="https://facebook.github.io/immutable-js/docs/#/List"&gt;List&lt;/a&gt;, &lt;a href="https://facebook.github.io/immutable-js/docs/#/Stack"&gt;Stack&lt;/a&gt;, &lt;a href="https://facebook.github.io/immutable-js/docs/#/Map"&gt;Map&lt;/a&gt;, &lt;a href="https://facebook.github.io/immutable-js/docs/#/OrderedMap"&gt;OrderedMap&lt;/a&gt;, &lt;a href="https://facebook.github.io/immutable-js/docs/#/Set"&gt;Set&lt;/a&gt;, &lt;a href="https://facebook.github.io/immutable-js/docs/#/OrderedSet"&gt;OrderedSet&lt;/a&gt;, and &lt;a href="https://facebook.github.io/immutable-js/docs/#/Record"&gt;Record&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;  &lt;a href="https://github.com/rtfeldman/seamless-immutable"&gt;Seamless-immutable&lt;/a&gt;: A library for immutable JavaScript data structures that are backward-compatible with normal arrays and objects.&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://github.com/aweary/react-copy-write"&gt;React-copy-write&lt;/a&gt;: An immutable React state management library with a simple mutable API, memoized selectors, and structural sharing.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Pro Tip:&lt;/strong&gt;  React &lt;code&gt;setState&lt;/code&gt; method is asynchronous. This means that rather than immediately mutating &lt;code&gt;this.state&lt;/code&gt;, &lt;code&gt;setState()&lt;/code&gt; creates a pending state transition. If you access &lt;code&gt;this.state&lt;/code&gt; after calling this method, it would potentially return the existing value. To prevent this, use the callback function of &lt;code&gt;setState&lt;/code&gt; to run code after the call is completed.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Additional Resources:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://swizec.com/blog/immutable-data/swizec/7613"&gt;Do you really need immutable data?&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://medium.com/dailyjs/the-state-of-immutability-169d2cd11310"&gt;The State of Immutability&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://reactkungfu.com/2015/08/pros-and-cons-of-using-immutability-with-react-js/"&gt;Pros and Cons of using immutability with React.js&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://medium.freecodecamp.org/handling-state-in-react-four-immutable-approaches-to-consider-d1f5c00249d5"&gt;Handling State in React: Four Immutable Approaches to Consider&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;em&gt;The original post, &lt;strong&gt;21 Performance Optimization Techniques for React Apps&lt;/strong&gt;, is published on the &lt;a href="https://www.codementor.io/blog/react-optimization-5wiwjnf9hj?utm_campaign=mkt-outreach&amp;amp;&amp;amp;utm_source=devto&amp;amp;utm_term=react-opt"&gt;Codementor Blog&lt;/a&gt;&lt;/em&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  2. Function/Stateless Components and React.PureComponent
&lt;/h2&gt;

&lt;p&gt;In React, function components and &lt;code&gt;PureComponent&lt;/code&gt; provide two different ways of optimizing React apps at the component level.&lt;/p&gt;

&lt;p&gt;Function components prevent constructing class instances while reducing the overall bundle size as it minifies better than classes. &lt;/p&gt;

&lt;p&gt;On the other hand, in order to optimize UI updates, we can consider converting function components to a &lt;code&gt;PureComponent&lt;/code&gt; class (or a class with a custom &lt;code&gt;shouldComponentUpdate&lt;/code&gt; method). However, if the component doesn’t use state and other life cycle methods, the initial render time is a bit more complicated when compared to function components with potentially faster updates.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;When should we use &lt;code&gt;React.PureComponent&lt;/code&gt;?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;React.PureComponent&lt;/code&gt; does a shallow comparison on state change. This means it compares values when looking at primitive data types, and compares references for objects. Due to this, we must make sure two criteria are met when using &lt;code&gt;React.PureComponent&lt;/code&gt;: &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Component State/Props is an immutable object;&lt;/li&gt;
&lt;li&gt;State/Props should not have a multi-level nested object. &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Pro Tip:&lt;/strong&gt; All child components of &lt;code&gt;React.PureComponent&lt;/code&gt; should also be a Pure or functional component.&lt;/p&gt;

&lt;h2&gt;
  
  
  3. Multiple Chunk Files
&lt;/h2&gt;

&lt;p&gt;Your application always begins with a few components. You start adding new features and dependencies, and before you know it, you end up with a huge production file.&lt;/p&gt;

&lt;p&gt;You can consider having two separate files by separating your vendor, or third-party library code from your application code by taking advantage of &lt;a href="https://webpack.js.org/plugins/commons-chunk-plugin/"&gt;CommonsChunkPlugin&lt;/a&gt; for webpack. You’ll end up with &lt;code&gt;vendor.bundle.js&lt;/code&gt; and &lt;code&gt;app.bundle.js&lt;/code&gt;. By splitting your files, your browser caches less frequently and parallel downloads resources to reduce load time wait.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Note:&lt;/strong&gt; If you are using the latest version of webpack, you can also consider &lt;a href="https://webpack.js.org/plugins/split-chunks-plugin/"&gt;SplitChunksPlugin&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  4.Using Production Mode Flag in Webpack
&lt;/h2&gt;

&lt;p&gt;If you are using &lt;code&gt;webpack 4&lt;/code&gt; as a module bundler for your app, you can consider setting the mode option to &lt;strong&gt;production&lt;/strong&gt;. This basically tells webpack to use the built-in optimization:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;    &lt;span class="nx"&gt;module&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;exports&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="na"&gt;mode&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;production&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;
    &lt;span class="p"&gt;};&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Alternatively, you can pass it as a CLI argument:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nx"&gt;webpack&lt;/span&gt; &lt;span class="o"&gt;--&lt;/span&gt;&lt;span class="nx"&gt;mode&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nx"&gt;production&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Doing this will limit optimizations, such as minification or removing development-only code, to libraries. It will not expose source code, file paths, and &lt;a href="https://medium.com/webpack/webpack-4-mode-and-optimization-5423a6bc597a"&gt;many more&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  5.Dependency optimization
&lt;/h2&gt;

&lt;p&gt;When considering optimizing the application bundle size, it’s worth checking how much code you are actually utilizing from dependencies. For example, you could be using &lt;code&gt;Moment.js&lt;/code&gt; which includes localized files for multi-language support. If you don’t need to support multiple languages, then you can consider using &lt;a href="https://www.npmjs.com/package/moment-locales-webpack-plugin"&gt;moment-locales-webpack-plugin&lt;/a&gt; to remove unused locales for your final bundle. &lt;/p&gt;

&lt;p&gt;Another example is &lt;code&gt;loadash&lt;/code&gt;. Let’s say you are only using 20 of the 100+ methods, then having all the extra methods in your final bundle is not optimal. So for this, you can use &lt;a href="https://github.com/lodash/lodash-webpack-plugin"&gt;lodash-webpack-plugin&lt;/a&gt; to remove unused functions.&lt;/p&gt;

&lt;p&gt;Here is an extensive list of &lt;a href="https://github.com/GoogleChromeLabs/webpack-libs-optimizations"&gt;dependencies&lt;/a&gt; which you can optimize.&lt;/p&gt;

&lt;h2&gt;
  
  
  6. Use &lt;code&gt;React.Fragments&lt;/code&gt; to Avoid Additional HTML Element Wrappers
&lt;/h2&gt;

&lt;p&gt;&lt;code&gt;React.fragments&lt;/code&gt; lets you group a list of children without adding an extra node.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nx"&gt;Comments&lt;/span&gt; &lt;span class="kd"&gt;extends&lt;/span&gt; &lt;span class="nx"&gt;React&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;PureComponent&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nx"&gt;render&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;
            &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;React&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;Fragment&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
                &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;h1&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="nx"&gt;Comment&lt;/span&gt; &lt;span class="nx"&gt;Title&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/h1&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;                &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;p&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="nx"&gt;comments&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/p&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;                &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;p&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="nx"&gt;comment&lt;/span&gt; &lt;span class="nx"&gt;time&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/p&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;            &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/React.Fragment&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;        &lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt; 
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;But wait! There is the alternate and more concise syntax using &lt;code&gt;React.fragments&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nx"&gt;Comments&lt;/span&gt; &lt;span class="kd"&gt;extends&lt;/span&gt; &lt;span class="nx"&gt;React&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;PureComponent&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nx"&gt;render&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;
            &lt;span class="o"&gt;&amp;lt;&amp;gt;&lt;/span&gt;
                &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;h1&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="nx"&gt;Comment&lt;/span&gt; &lt;span class="nx"&gt;Title&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/h1&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;                &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;p&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="nx"&gt;comments&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/p&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;                &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;p&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="nx"&gt;comment&lt;/span&gt; &lt;span class="nx"&gt;time&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/p&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;            &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;        &lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt; 
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  7. Avoid Inline Function Definition in the Render Function.
&lt;/h2&gt;

&lt;p&gt;Since functions are objects in JavaScript (&lt;code&gt;{} !== {}&lt;/code&gt;), the inline function will always fail the prop diff when React does a diff check. Also, an arrow function will create a new instance of the function on each render if it's used in a JSX property. This might create a lot of work for the garbage collector.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="k"&gt;default&lt;/span&gt; &lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nx"&gt;CommentList&lt;/span&gt; &lt;span class="kd"&gt;extends&lt;/span&gt; &lt;span class="nx"&gt;React&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;Component&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nx"&gt;state&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="na"&gt;comments&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[],&lt;/span&gt;
        &lt;span class="na"&gt;selectedCommentId&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;null&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;

    &lt;span class="nx"&gt;render&lt;/span&gt;&lt;span class="p"&gt;(){&lt;/span&gt;
        &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;comments&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;state&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;
           &lt;span class="nx"&gt;comments&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;map&lt;/span&gt;&lt;span class="p"&gt;((&lt;/span&gt;&lt;span class="nx"&gt;comment&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;=&amp;gt;&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
               &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;Comment&lt;/span&gt; &lt;span class="nx"&gt;onClick&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{(&lt;/span&gt;&lt;span class="nx"&gt;e&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;=&amp;gt;&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
                    &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;setState&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;&lt;span class="na"&gt;selectedCommentId&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="nx"&gt;comment&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;commentId&lt;/span&gt;&lt;span class="p"&gt;})&lt;/span&gt;
               &lt;span class="p"&gt;}}&lt;/span&gt; &lt;span class="nx"&gt;comment&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;comment&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="nx"&gt;key&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;comment&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;id&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="sr"&gt;/&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;           &lt;span class="p"&gt;})&lt;/span&gt; 
        &lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Instead of defining the inline function for props, you can define the arrow function.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="k"&gt;default&lt;/span&gt; &lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nx"&gt;CommentList&lt;/span&gt; &lt;span class="kd"&gt;extends&lt;/span&gt; &lt;span class="nx"&gt;React&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;Component&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nx"&gt;state&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="na"&gt;comments&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[],&lt;/span&gt;
        &lt;span class="na"&gt;selectedCommentId&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;null&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;

    &lt;span class="nx"&gt;onCommentClick&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;commentId&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;=&amp;gt;&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;setState&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;&lt;span class="na"&gt;selectedCommentId&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="nx"&gt;commentId&lt;/span&gt;&lt;span class="p"&gt;})&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;

    &lt;span class="nx"&gt;render&lt;/span&gt;&lt;span class="p"&gt;(){&lt;/span&gt;
        &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;comments&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;state&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;
           &lt;span class="nx"&gt;comments&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;map&lt;/span&gt;&lt;span class="p"&gt;((&lt;/span&gt;&lt;span class="nx"&gt;comment&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;=&amp;gt;&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
               &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;Comment&lt;/span&gt; &lt;span class="nx"&gt;onClick&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;onCommentClick&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt; 
                &lt;span class="nx"&gt;comment&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;comment&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="nx"&gt;key&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;comment&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;id&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="sr"&gt;/&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;           &lt;span class="p"&gt;})&lt;/span&gt; 
        &lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  8. Throttling and Debouncing Event Action in JavaScript
&lt;/h2&gt;

&lt;p&gt;Event trigger rate is the number of times an event handler invokes in a given amount of time.&lt;/p&gt;

&lt;p&gt;In general, mouse clicks have lower event trigger rates compare to scrolling and mouseover. Higher event trigger rates can sometimes crash your application, but it can be controlled.&lt;/p&gt;

&lt;p&gt;Let's discuss some of the techniques.&lt;/p&gt;

&lt;p&gt;First, identify the event handler that is doing the expensive work. For example, an XHR request or DOM manipulation that performs UI updates, processes a large amount of data, or perform computation expensive tasks. In these cases, throttling and debouncing techniques can be a savior without making any changes in the event listener.&lt;/p&gt;

&lt;h4&gt;
  
  
  Throttling
&lt;/h4&gt;

&lt;p&gt;In a nutshell, throttling means delaying function execution. So instead of executing the event handler/function immediately, you’ll be adding a few milliseconds of delay when an event is triggered. This can be used when implementing infinite scrolling, for example. Rather than fetching the next result set as the user is scrolling, you can delay the XHR call.&lt;/p&gt;

&lt;p&gt;Another good example of this is Ajax-based instant search. You might not want to hit the server for every key press, so it’s better to throttle until the input field is dormant for a few milliseconds&lt;/p&gt;

&lt;p&gt;Throttling can be implemented a number of ways. You can throttle by the number of events triggered or by the delay event handler being executed.&lt;/p&gt;

&lt;h4&gt;
  
  
  Debouncing
&lt;/h4&gt;

&lt;p&gt;Unlike throttling, debouncing is a technique to prevent the event trigger from being fired too often. If you are using &lt;code&gt;lodash&lt;/code&gt;, you can wrap the function you want to call in &lt;code&gt;lodash’s  debounce function&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Here’s a demo code for searching comments:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;debouce&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;lodash.debounce&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nx"&gt;SearchComments&lt;/span&gt; &lt;span class="kd"&gt;extends&lt;/span&gt; &lt;span class="nx"&gt;React&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;Component&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
 &lt;span class="kd"&gt;constructor&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;props&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
   &lt;span class="k"&gt;super&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;props&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
   &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;state&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;searchQuery&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="err"&gt;“”&lt;/span&gt; &lt;span class="p"&gt;};&lt;/span&gt;
 &lt;span class="p"&gt;}&lt;/span&gt;

 &lt;span class="nx"&gt;setSearchQuery&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;debounce&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;e&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
   &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;setState&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt; &lt;span class="na"&gt;searchQuery&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;e&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;target&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;value&lt;/span&gt; &lt;span class="p"&gt;});&lt;/span&gt;

   &lt;span class="c1"&gt;// Fire API call or Comments manipulation on client end side&lt;/span&gt;
 &lt;span class="p"&gt;},&lt;/span&gt; &lt;span class="mi"&gt;1000&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

 &lt;span class="nx"&gt;render&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
   &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;
     &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;div&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
       &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;h1&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="nx"&gt;Search&lt;/span&gt; &lt;span class="nx"&gt;Comments&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/h1&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;       &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;input&lt;/span&gt; &lt;span class="nx"&gt;type&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;text&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="nx"&gt;onChange&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;setSearchQuery&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="sr"&gt;/&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;     &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/div&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;   &lt;span class="p"&gt;);&lt;/span&gt;
 &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If you are not using &lt;code&gt;lodash&lt;/code&gt;, you can use the minified debounced function to implement it in JavaScript.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nx"&gt;debounce&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;a&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="nx"&gt;b&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="nx"&gt;c&lt;/span&gt;&lt;span class="p"&gt;){&lt;/span&gt;&lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="nx"&gt;d&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="nx"&gt;e&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;&lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt;&lt;span class="p"&gt;(){&lt;/span&gt;&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nx"&gt;h&lt;/span&gt;&lt;span class="p"&gt;(){&lt;/span&gt;&lt;span class="nx"&gt;d&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="kc"&gt;null&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="nx"&gt;c&lt;/span&gt;&lt;span class="o"&gt;||&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;e&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nx"&gt;a&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;apply&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;f&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="nx"&gt;g&lt;/span&gt;&lt;span class="p"&gt;))}&lt;/span&gt;&lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="nx"&gt;f&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="nx"&gt;g&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nx"&gt;arguments&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;&lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;clearTimeout&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;d&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;&lt;span class="nx"&gt;d&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nx"&gt;setTimeout&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;h&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="nx"&gt;b&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;&lt;span class="nx"&gt;c&lt;/span&gt;&lt;span class="o"&gt;&amp;amp;&amp;amp;!&lt;/span&gt;&lt;span class="nx"&gt;d&lt;/span&gt;&lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;e&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nx"&gt;a&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;apply&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;f&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="nx"&gt;g&lt;/span&gt;&lt;span class="p"&gt;)),&lt;/span&gt;&lt;span class="nx"&gt;e&lt;/span&gt;&lt;span class="p"&gt;}}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Reference and Related Articles:&lt;/strong&gt;&lt;br&gt;
&lt;a href="https://lodash.com/docs/#debounce"&gt;"Array" Methods&lt;/a&gt;,&lt;br&gt;
&lt;a href="https://eloquentjavascript.net/15_event.html"&gt;Handling Events&lt;/a&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  9. Avoid using Index as Key for map
&lt;/h2&gt;

&lt;p&gt;You often see indexes being used as a key when rendering a list.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nx"&gt;comments&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;map&lt;/span&gt;&lt;span class="p"&gt;((&lt;/span&gt;&lt;span class="nx"&gt;comment&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;index&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;Comment&lt;/span&gt; 
            &lt;span class="p"&gt;{..&lt;/span&gt;&lt;span class="nx"&gt;comment&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
            &lt;span class="nx"&gt;key&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;index&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="sr"&gt;/&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;    &lt;span class="p"&gt;})&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;But using the key as the index can show your app incorrect data as it is being used to identify DOM elements. When you push or remove an item from the list, if the key is the same as before, React assumes that the DOM element represents the same component.&lt;/p&gt;

&lt;p&gt;It's always advisable to use a unique property as a key, or if your data doesn't have any unique attributes, then you can think of using the &lt;code&gt;shortid module&lt;/code&gt; which generates a unique key.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;shortid&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt;  &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;shortid&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nx"&gt;comments&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;map&lt;/span&gt;&lt;span class="p"&gt;((&lt;/span&gt;&lt;span class="nx"&gt;comment&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;index&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;Comment&lt;/span&gt; 
            &lt;span class="p"&gt;{..&lt;/span&gt;&lt;span class="nx"&gt;comment&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
            &lt;span class="nx"&gt;key&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;shortid&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;generate&lt;/span&gt;&lt;span class="p"&gt;()}&lt;/span&gt; &lt;span class="sr"&gt;/&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;    &lt;span class="p"&gt;})&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;However, if the data has a unique property, such as an ID, then it's better to use that property.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nx"&gt;comments&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;map&lt;/span&gt;&lt;span class="p"&gt;((&lt;/span&gt;&lt;span class="nx"&gt;comment&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;index&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;Comment&lt;/span&gt; 
            &lt;span class="p"&gt;{..&lt;/span&gt;&lt;span class="nx"&gt;comment&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
            &lt;span class="nx"&gt;key&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;comment&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;id&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="sr"&gt;/&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;    &lt;span class="p"&gt;})&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In certain cases, it's completely okay to use the index as the key, but only if below condition holds:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;  The list and items are static&lt;/li&gt;
&lt;li&gt;  The items in the list don't have IDs and the list is never going to be reordered or filtered&lt;/li&gt;
&lt;li&gt;  List is immutable&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;References and Related Articles:&lt;/strong&gt;&lt;br&gt;
&lt;a href="https://github.com/facebook/react/issues/1342#issuecomment-39230939"&gt;Consider providing a default key for dynamic children #1342&lt;/a&gt;,&lt;br&gt;
&lt;a href="https://coderwall.com/p/jdybeq/the-importance-of-component-keys-in-react-js"&gt;The importance of component keys in React.js&lt;/a&gt;,&lt;br&gt;
&lt;a href="https://paulgray.net/keys-in-react/"&gt;Why you need keys for collections in React&lt;/a&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  10. Avoiding Props in Initial States
&lt;/h2&gt;

&lt;p&gt;We often need to pass initial data with props to the React component to set the initial state value.&lt;/p&gt;

&lt;p&gt;Let's consider this code:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nx"&gt;EditPanelComponent&lt;/span&gt; &lt;span class="kd"&gt;extends&lt;/span&gt; &lt;span class="nx"&gt;Component&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;

    &lt;span class="kd"&gt;constructor&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;props&lt;/span&gt;&lt;span class="p"&gt;){&lt;/span&gt;
        &lt;span class="k"&gt;super&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;props&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

        &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;state&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
            &lt;span class="na"&gt;isEditMode&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;false&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
            &lt;span class="na"&gt;applyCoupon&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;props&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;applyCoupon&lt;/span&gt;
        &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;

    &lt;span class="nx"&gt;render&lt;/span&gt;&lt;span class="p"&gt;(){&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;div&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
                    &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;state&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;applyCoupon&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; 
                    &lt;span class="o"&gt;&amp;lt;&amp;gt;&lt;/span&gt;&lt;span class="nx"&gt;Enter&lt;/span&gt; &lt;span class="na"&gt;Coupon&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;Input&lt;/span&gt;&lt;span class="o"&gt;/&amp;gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/&amp;gt;&lt;/span&gt;&lt;span class="err"&gt;}
&lt;/span&gt;               &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/div&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;    &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Everything looks good in the snippet, right?&lt;/p&gt;

&lt;p&gt;But what happens when &lt;code&gt;props.applyCoupon&lt;/code&gt; changes? Will it be reflected in the state? If the props are changed without the refreshing the component, the new prop value will never be assigned to the state’s &lt;code&gt;applyCoupon&lt;/code&gt;. This is because the constructor function is only called when &lt;code&gt;EditPanelComponent&lt;/code&gt; is first created.&lt;/p&gt;

&lt;p&gt;To quote &lt;strong&gt;React docs&lt;/strong&gt;: &lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Using props to initialize a state in constructor function often leads to duplication of “source of truth”, i.e. where the real data is. This is because constructor function is only invoked when the component is first created.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;strong&gt;Workaround:&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Don't initialize state with props which can be changed later. Instead, use props directly in the component.
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nx"&gt;EditPanelComponent&lt;/span&gt; &lt;span class="kd"&gt;extends&lt;/span&gt; &lt;span class="nx"&gt;Component&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;

    &lt;span class="kd"&gt;constructor&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;props&lt;/span&gt;&lt;span class="p"&gt;){&lt;/span&gt;
        &lt;span class="k"&gt;super&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;props&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

        &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;state&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
            &lt;span class="na"&gt;isEditMode&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;false&lt;/span&gt;
        &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;

    &lt;span class="nx"&gt;render&lt;/span&gt;&lt;span class="p"&gt;(){&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;div&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;props&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;applyCoupon&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; 
         &lt;span class="o"&gt;&amp;lt;&amp;gt;&lt;/span&gt;&lt;span class="nx"&gt;Enter&lt;/span&gt; &lt;span class="na"&gt;Coupon&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;Input&lt;/span&gt;&lt;span class="o"&gt;/&amp;gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/&amp;gt;}&amp;lt;/&lt;/span&gt;&lt;span class="nx"&gt;div&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt; 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;You can use &lt;code&gt;componentWillReceiveProps&lt;/code&gt; to update the state when props change.
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nx"&gt;EditPanelComponent&lt;/span&gt; &lt;span class="kd"&gt;extends&lt;/span&gt; &lt;span class="nx"&gt;Component&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;

    &lt;span class="kd"&gt;constructor&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;props&lt;/span&gt;&lt;span class="p"&gt;){&lt;/span&gt;
        &lt;span class="k"&gt;super&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;props&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

        &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;state&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
            &lt;span class="na"&gt;isEditMode&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;false&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
            &lt;span class="na"&gt;applyCoupon&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;props&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;applyCoupon&lt;/span&gt;
        &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;

    &lt;span class="c1"&gt;// reset state if the seeded prop is updated&lt;/span&gt;
    &lt;span class="nx"&gt;componentWillReceiveProps&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;nextProps&lt;/span&gt;&lt;span class="p"&gt;){&lt;/span&gt;
        &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;nextProps&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;applyCoupon&lt;/span&gt; &lt;span class="o"&gt;!==&lt;/span&gt; &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;props&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;applyCoupon&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
            &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;setState&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt; &lt;span class="na"&gt;applyCoupon&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;nextProps&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;applyCoupon&lt;/span&gt; &lt;span class="p"&gt;})&lt;/span&gt;
        &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;

    &lt;span class="nx"&gt;render&lt;/span&gt;&lt;span class="p"&gt;(){&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;div&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;props&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;applyCoupon&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; 
          &lt;span class="o"&gt;&amp;lt;&amp;gt;&lt;/span&gt;&lt;span class="nx"&gt;Enter&lt;/span&gt; &lt;span class="na"&gt;Coupon&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;Input&lt;/span&gt;&lt;span class="o"&gt;/&amp;gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/&amp;gt;}&amp;lt;/&lt;/span&gt;&lt;span class="nx"&gt;div&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;References and Related Articles:&lt;/strong&gt;&lt;br&gt;
&lt;a href="https://stackoverflow.com/questions/28785106/reactjs-why-is-passing-the-component-initial-state-a-prop-an-anti-pattern"&gt;ReactJS: Why is passing the component initial state a prop an anti-pattern?&lt;/a&gt;,&lt;br&gt;
&lt;a href="https://medium.com/@justintulk/react-anti-patterns-props-in-initial-state-28687846cc2e"&gt;React Anti-Patterns: Props in Initial State&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;There are many ways to optimize a React app, for example lazy loading components, using ServiceWorkers to cache application state, considering SSR, avoiding unnecessary renders etc.. That said, before considering optimization, it’s worth understanding how React components work, understanding diffing algorithms, and how rendering works in React. These are all important concepts to take into consideration when optimizing your application.&lt;/p&gt;

&lt;p&gt;I think optimization without measuring is almost premature, which is why I would recommend to benchmark and measure performance first. You can consider profiling and visualizing components with Chrome Timeline. This lets you see which components are unmounted, mounted, updated, and how much time they take relative to each other. It will help you to get started with your performance optimization journey.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;For more tips, head over to the &lt;a href="https://www.codementor.io/blog/react-optimization-5wiwjnf9hj?utm_campaign=mkt-outreach&amp;amp;&amp;amp;utm_source=devto&amp;amp;utm_term=react-opt"&gt;Codementor Blog&lt;/a&gt; to read the original post, &lt;strong&gt;21 Performance Optimization Techniques for React Apps&lt;/strong&gt;.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>react</category>
      <category>javascript</category>
    </item>
    <item>
      <title>3 hours left to win a $75 Amazon giftcard!</title>
      <dc:creator>Codementor</dc:creator>
      <pubDate>Tue, 13 Aug 2019 03:34:05 +0000</pubDate>
      <link>https://forem.com/codementor/3-hours-left-to-win-a-75-amazon-giftcard-37pj</link>
      <guid>https://forem.com/codementor/3-hours-left-to-win-a-75-amazon-giftcard-37pj</guid>
      <description>&lt;p&gt;Share &lt;em&gt;your&lt;/em&gt; experience as a &lt;strong&gt;remote developer or technical leader&lt;/strong&gt; in our  5-minute “State of Remote Developers” survey. The &lt;strong&gt;survey closes in 3 hours&lt;/strong&gt;!! &lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;&lt;a href="https://codemntr.io/devto-stateofremotedevs"&gt;👉 SURVEY HERE&lt;/a&gt;&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;Two $75 Amazon giftcards are up for grabs and winners will be contacted by the end of the week. 🎉&lt;/p&gt;

</description>
      <category>survey</category>
      <category>giftcard</category>
      <category>developers</category>
      <category>remote</category>
    </item>
    <item>
      <title>1 week left to win a $75 Amazon giftcard!</title>
      <dc:creator>Codementor</dc:creator>
      <pubDate>Thu, 08 Aug 2019 06:50:53 +0000</pubDate>
      <link>https://forem.com/codementor/1-week-left-to-win-a-75-amazon-giftcard-4dc8</link>
      <guid>https://forem.com/codementor/1-week-left-to-win-a-75-amazon-giftcard-4dc8</guid>
      <description>&lt;p&gt;Share &lt;em&gt;your&lt;/em&gt; experience as a &lt;strong&gt;remote developer or technical leader&lt;/strong&gt; in our  5-minute “State of Remote Developers” survey. The &lt;strong&gt;survey closes EOD Monday, August 12th&lt;/strong&gt;! &lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;&lt;a href="https://codemntr.io/devto-stateofremotedevs"&gt;👉 SURVEY HERE&lt;/a&gt;&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;Two $75 Amazon giftcards are up for grabs and winners will be contacted mid-August. 🎉&lt;/p&gt;

</description>
      <category>survey</category>
      <category>remote</category>
      <category>developers</category>
    </item>
    <item>
      <title>“State of Remote Developers 2019” Survey (win an Amazon giftcard!)</title>
      <dc:creator>Codementor</dc:creator>
      <pubDate>Tue, 23 Jul 2019 08:55:25 +0000</pubDate>
      <link>https://forem.com/codementor/state-of-remote-developers-2019-survey-win-an-amazon-giftcard-1498</link>
      <guid>https://forem.com/codementor/state-of-remote-developers-2019-survey-win-an-amazon-giftcard-1498</guid>
      <description>&lt;p&gt;Share &lt;em&gt;your&lt;/em&gt; experience and complete the &lt;strong&gt;5-minute “State of Remote Developers” survey before Monday, August 12th&lt;/strong&gt;! In our final report, we'll compare insights on how remote developers work and what support they need to excel, with the perspective of technical leaders.&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;&lt;a href="https://codemntr.io/devto-stateofremotedevs"&gt;SURVEY HERE&lt;/a&gt;&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;You'll be entered to &lt;strong&gt;win a $75 Amazon giftcard&lt;/strong&gt;. Two winners will be contacted mid-August.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;In your opinion, what is the one biggest obstacle that prevents companies from adopting remote work?&lt;/em&gt;&lt;/p&gt;

</description>
      <category>survey</category>
      <category>remote</category>
      <category>developers</category>
    </item>
    <item>
      <title>What it Means to be a Woman in Tech in 2019</title>
      <dc:creator>Codementor</dc:creator>
      <pubDate>Fri, 08 Mar 2019 10:27:49 +0000</pubDate>
      <link>https://forem.com/codementor/what-it-means-to-be-a-women-in-tech-in-2019--4el6</link>
      <guid>https://forem.com/codementor/what-it-means-to-be-a-women-in-tech-in-2019--4el6</guid>
      <description>&lt;p&gt;Today is International Women’s Day!&lt;/p&gt;

&lt;p&gt;Last weekend, &lt;em&gt;60 minutes&lt;/em&gt; aired a segment on girls in computer science and closing the gender gap in tech — without referencing any (of the many) women-led efforts. Reshma Saujani, Founder of Girls Who Code spoke out about this in a &lt;a href="https://onezero.medium.com/erasing-women-in-tech-how-60-minutes-ignored-womens-voices-stories-and-expertise-7ee8e157c262?fbclid=IwAR1-NBCoIbrewsihUtTB5zWn2ytGsPd6D73UiJmFTtIcYKy8m5pFIbGrl8Q" rel="noopener noreferrer"&gt;recent blog post&lt;/a&gt;, and how the media tends to overlook the contribution of women in tech.&lt;/p&gt;

&lt;p&gt;“Contrary to what was said in the program, introducing girls to computer science earlier on (i.e. kindergarten) isn’t enough to close the gender gap in tech. &lt;strong&gt;Girls need support systems all along the pipeline&lt;/strong&gt;, and tech companies need to do their part to root out harassment and discrimination,” Reshma says.&lt;/p&gt;

&lt;p&gt;For this post, I wanted to put female developers in the spotlight and highlight their experiences in the tech industry. There are many amazing role models out there making progress, big and small, that should be shared and celebrated. Let’s hear what they have to say!&lt;/p&gt;

&lt;h2&gt;
  
  
  Being a role model
&lt;/h2&gt;

&lt;p&gt;Research done by &lt;a href="https://cs.stanford.edu/people/eroberts/cs201/projects/women-in-cs/stayingwithcs.html" rel="noopener noreferrer"&gt;Stanford's&lt;/a&gt; Computer Science department concludes the lack of role models as one of the main reasons why women no longer choose to pursue Computer Science.&lt;/p&gt;

&lt;p&gt;Perhaps part of the issue here is visibility. Aside from Ada Lovelace, there are &lt;strong&gt;several&lt;/strong&gt; &lt;a href="https://twitter.com/CodementorIO/status/1102503325050781696" rel="noopener noreferrer"&gt;notable female developers&lt;/a&gt; that have made a significant impact on software development as we know it today, but most developers may not have ever heard of them. &lt;/p&gt;

&lt;p&gt;The women we spoke to also named other inspiring female developers, including &lt;strong&gt;Gwen Barzey&lt;/strong&gt; (a &lt;a href="http://braythwayt.com/posterous/2012/03/29/a-womans-story.html" rel="noopener noreferrer"&gt;black Toronto women&lt;/a&gt; who was one of the first programmers in Canada), &lt;strong&gt;Linda Liukas&lt;/strong&gt; (co-founded &lt;a href="http://railsgirls.com/" rel="noopener noreferrer"&gt;Rails Girls&lt;/a&gt; and helped make programming “more approachable”), &lt;strong&gt;Sandi Metz&lt;/strong&gt; (&lt;a href="https://www.poodr.com/" rel="noopener noreferrer"&gt;author&lt;/a&gt; and speaker who’s “passionate about advancing the craft of programming”). These role models are not only trailblazers who have shown that they’re integral to this field, they’re also advocates whose stories help empower others.&lt;/p&gt;

&lt;p&gt;Whether you’re a junior or senior developer, you &lt;em&gt;can&lt;/em&gt; inspire others even if you feel like you haven’t done something that’s unconventional. Being a guide for other women who are in, or interested in, the tech industry can make a small but significant impact.&lt;/p&gt;

&lt;p&gt;If you’re reading this, you can still be a role model to other women, even if you’re &lt;em&gt;not&lt;/em&gt; a developer or a women! Some developers told us that they were inspired by people like &lt;strong&gt;Malalal Yousafzai&lt;/strong&gt;, &lt;strong&gt;Melinda (and Bill) Gates&lt;/strong&gt;, &lt;strong&gt;Michelle Obama&lt;/strong&gt;, and others. A few were also greatly inspired by the male figures in their lives, whether it's their father, spouse, peers, or colleagues in more senior roles. &lt;/p&gt;

&lt;h2&gt;
  
  
  Not being afraid of failure
&lt;/h2&gt;

&lt;p&gt;A common challenge that's faced — one that not only resonates with women developers but also many developers who are just starting out — is the dreaded &lt;a href="https://insights.dice.com/2016/05/06/overcoming-imposter-syndrome/" rel="noopener noreferrer"&gt;imposter syndrome&lt;/a&gt;, when you feel like you are undeserving of your role and have an overall lack of confidence.&lt;/p&gt;

&lt;p&gt;As Jaime Gunther, software engineer at &lt;a href="https://envato.com" rel="noopener noreferrer"&gt;Envato&lt;/a&gt;, puts it:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;When you’re a developer, particularly a junior, &lt;strong&gt;everyday is a huge learning experience&lt;/strong&gt;. You are solving problems and debugging issues and it can get frustrating. In those moments of frustration it’s really easy to fall into the trap of not feeling good enough, not feeling capable etc. &lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Mary Kate Fain, software engineer at &lt;a href="https://www.promptworks.com" rel="noopener noreferrer"&gt;Promptworks&lt;/a&gt;, believes that "overcoming fear and self doubt is a greater challenge than learning any one programming language or skill". She believes this issue goes back even further, and cites Reshma Saujani (author and founder of Girls Who Code), who said that girls are taught to strive for perfection, rather than encouraged to be brave. &lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;We don't learn how to deal with failure, which prevents us from tackling new challenges and leads to self handicapping. — Mary Kate Fain&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;The key to overcoming this, according to Jaime, is to "acknowledge the situation, take a deep breath, realise that everyone has those moments, and be kind to yourself."&lt;/p&gt;

&lt;h2&gt;
  
  
  Capitalizing on your strengths
&lt;/h2&gt;

&lt;p&gt;Being a female developer makes you “automatically memorable”, according to &lt;a href="https://www.codementor.io/sheena" rel="noopener noreferrer"&gt;Sheena&lt;/a&gt;, a Python mentor on Codementor. Figuring out your strengths helps you learn how you can use them to gain a higher sense of confidence and boost your career as a developer. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn.filestackcontent.com%2Fyk72D4SkTdaJu8cX6O5J" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn.filestackcontent.com%2Fyk72D4SkTdaJu8cX6O5J" alt="monica-female-developer-womens-day-learning.png"&gt;&lt;/a&gt;&lt;em&gt;Quote by &lt;a href="https://www.codementor.io/monicaolinescu" rel="noopener noreferrer"&gt;Monica Olinescu&lt;/a&gt;. Senior Developer, Technical Lead, and Mentor&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;If you’re feeling lost and not sure where to start, &lt;a href="https://www.codementor.io/jellenekhoh" rel="noopener noreferrer"&gt;Jellene Khoh&lt;/a&gt; recommends to “learn a framework if you want to get a job, learn to handle data if you want to go far.”&lt;/p&gt;

&lt;p&gt;Even if you don’t have a background in tech, Jay Strawn at &lt;a href="https://utilitynyc.com/" rel="noopener noreferrer"&gt;Utility NYC&lt;/a&gt; (and previously a literature major), says that “finding a way to use the skills I already had and apply them to tech really helped me learn and grow in my career.”&lt;/p&gt;

&lt;h2&gt;
  
  
  Mentoring others
&lt;/h2&gt;

&lt;p&gt;Most of the female developers I spoke to had mentors that played a key role in their career growth. Not all mentors did something innovative, nor were they all women.&lt;/p&gt;

&lt;p&gt;Mentoring is often a two-way street. Mentors I’ve spoken to in the past have also learned a lot from their mentees and feel a sense of pride when they see their mentees succeed. In 2019, the rest of the Codementor team and I hope to encourage and see more women developers to be mentors in this space.&lt;/p&gt;

&lt;p&gt;For &lt;a href="https://www.codementor.io/jessamynsmith" rel="noopener noreferrer"&gt;Jessamyn Smith&lt;/a&gt;, being a mentor has helped put an end to her biggest challenge in the workplace. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn.filestackcontent.com%2FzawqmUzCTi9w1agTeEGN" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn.filestackcontent.com%2FzawqmUzCTi9w1agTeEGN" alt="women-in-tech-jessamyn-developer-mentor.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Not being afraid of asking questions
&lt;/h2&gt;

&lt;p&gt;When you start your first job as a developer, sometimes you don’t &lt;em&gt;really&lt;/em&gt; know what you’re getting into until you start being more hands on. For &lt;a href="https://www.codementor.io/jadwigapokorska" rel="noopener noreferrer"&gt;Jadwiga Pokorska&lt;/a&gt;, who was previously a software engineer at Google, the size of the organization (and similarly, their codebase) meant that she had to get comfortable with asking others for help, like where something is in the code — even if it seemed like a “stupid” question.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;If you're in a project and you feel like something is not clear or not addressed completely, do speak up. More often than not, you're not the only one feeling this way and clarification will help everybody. — &lt;a href="https://www.codementor.io/carolinux" rel="noopener noreferrer"&gt;Karolina&lt;/a&gt;, Python mentor&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Sylvia, Codementor team's first female developer, shared that a big challenge she faced in her first job was having to work with a development team that lacked proper software development processes and documentation, which required constantly communicating with stakeholders about requirements. This also meant having the courage to ask questions and keeping people accountable to help put an end to working inefficiently.&lt;/p&gt;

&lt;h2&gt;
  
  
  Belonging to a supportive community
&lt;/h2&gt;

&lt;p&gt;As Mary Kate puts it:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Find your community. Having people to help me debug, show me what to learn next, teach me, inspire me, and encourage me when I'm down has made all the difference. Find out if you have a local women's tech organization, and attend all the meetups and classes you can. You'll learn skills you need, and the more importantly &lt;strong&gt;meet the connections that will keep you going&lt;/strong&gt;.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Surround yourself with people who have the same interests or background as you. There, you can interact with people who have been in your shoes, meet potential mentors, listen to inspirational talks, and much more.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn.filestackcontent.com%2FBP0xJJvTTW6xBKxaHRZ1" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn.filestackcontent.com%2FBP0xJJvTTW6xBKxaHRZ1" alt="senior-ibm-developer-sarah-eggleston-female.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Celebrating how far we've come
&lt;/h2&gt;

&lt;p&gt;International Women’s Day should also be a time to celebrate how far we’ve come to help push us forward.  &lt;/p&gt;

&lt;p&gt;So, &lt;strong&gt;what’s the best part about being a women in tech&lt;/strong&gt;? Here are some of their responses:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;“[It has] &lt;strong&gt;opened a number of doors for me&lt;/strong&gt; in companies that valued diversity.” — Monica&lt;/li&gt;
&lt;li&gt;“&lt;strong&gt;Problem solving&lt;/strong&gt;. When I (finally) fix a difficult bug, I hear the Indiana Jones theme tune playing in my head.” — Sarah&lt;/li&gt;
&lt;li&gt;“&lt;strong&gt;Meeting the other amazing women&lt;/strong&gt; in tech. The women who I meet have fought their way into these spaces, and are smarter and braver than most other people I know. Every time I get to meet another female technologist &lt;strong&gt;it gives me hope&lt;/strong&gt;, and revitalizes my own desire to succeed.” — Mary Kate&lt;/li&gt;
&lt;li&gt;“&lt;strong&gt;Mentoring other people&lt;/strong&gt; who belong to demographics that are underrepresented in tech.” — Jessamyn&lt;/li&gt;
&lt;li&gt;“I can prove that &lt;strong&gt;not only men&lt;/strong&gt; can do engineering.” — Wenyun at &lt;a href="https://www.codementor.io" rel="noopener noreferrer"&gt;Codementor&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;"Women in the tech community are &lt;strong&gt;extremely supportive&lt;/strong&gt; and, while there might not be many of us, our &lt;strong&gt;dedication and genuine desire to help&lt;/strong&gt; makes up for what we lack in numbers." — Diane at &lt;a href="https://www.gitkraken.com/" rel="noopener noreferrer"&gt;GitKraken&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn.filestackcontent.com%2FINVaCRSmSfKagQkR7p4g" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn.filestackcontent.com%2FINVaCRSmSfKagQkR7p4g" alt="empowering-women-in-tech-jellene.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I hope this post can inspire more women — and other underrepresented groups in tech — to feel encouraged, help one another, and come together to break the mold. For those who already in tech, keep up the great work! &lt;/p&gt;

&lt;p&gt;Lastly, a special thanks to all of the female developers who shared their experiences with me. Happy International Women's Day!&lt;/p&gt;

&lt;p&gt;&lt;em&gt;This post was originally published on Codementor's blog: &lt;a href="https://www.codementor.io/blog/women-in-tech-2019-6ev3m997u3" rel="noopener noreferrer"&gt;https://www.codementor.io/blog/women-in-tech-2019-6ev3m997u3&lt;/a&gt;&lt;/em&gt;&lt;/p&gt;

</description>
      <category>wecoded</category>
      <category>career</category>
      <category>womenintech</category>
      <category>womenwhocode</category>
    </item>
    <item>
      <title>7 Ways to Stay Motivated When Learning to Code</title>
      <dc:creator>Codementor</dc:creator>
      <pubDate>Tue, 26 Feb 2019 04:19:23 +0000</pubDate>
      <link>https://forem.com/codementor/7-ways-to-stay-motivated-when-learning-to-code-21if</link>
      <guid>https://forem.com/codementor/7-ways-to-stay-motivated-when-learning-to-code-21if</guid>
      <description>&lt;p&gt;Staying motivated is one of the hardest things to do when you're just starting out with programming. &lt;a href="https://dev.to/somedood/programming-is-hard-2p87"&gt;Programming is hard&lt;/a&gt;, so it's easy is to feel discouraged when you can't figure out why your code isn't working. You start struggling to wrap your head around &lt;a href="https://dev.to/trekhleb/algorithms-and-data-structures-in-javascript-49i3"&gt;complicated algorithms&lt;/a&gt;, or more advanced and abstract concepts. It can be really frustrating that progress seems like no progress at all. &lt;/p&gt;

&lt;p&gt;To help figure out the best ways to stay motivated, I asked several &lt;a href="https://www.codementor.io/freelance-developers/software?show=dev"&gt;experienced software developers&lt;/a&gt; about this topic, and here's what they told me. &lt;/p&gt;

&lt;p&gt;I hope these tips help you in your journey as they did for me! 🙂&lt;/p&gt;

&lt;h2&gt;
  
  
  1. Make sure this is actually something you want to do
&lt;/h2&gt;

&lt;blockquote&gt;
&lt;p&gt;There are few things more frustrating than doing something that has no point in the end.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;If coding is not something you want to do, then leave it to those who do. One of the first "&lt;a href="https://www.codementor.io/learn-programming/13-learning-hacks-for-when-teaching-yourself-how-to-code#/"&gt;learning hacks&lt;/a&gt;" for teaching yourself how to code is knowing &lt;em&gt;why&lt;/em&gt; you’re doing this. When your code is in knots and nothing is going your way, those are the times when remembering your purpose for learning code will help push you forward so that you can stay motivated and ease any frustration that you may have.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Motivation is good, but not the answer to keep you going in the long run. Become &lt;strong&gt;passionate&lt;/strong&gt; about what you do.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Sure you don’t need to be obsessed with all things code, nor do you need to be extremely passionate about coding from the start, Let's be real — these things don’t really happen overnight. It often comes after spending some time learning and understanding code, as well as creating simple things from scratch.&lt;br&gt;
​&lt;/p&gt;

&lt;h2&gt;
  
  
  2. Start small, celebrate the little things, and build, build, build!
&lt;/h2&gt;

&lt;blockquote&gt;
&lt;p&gt;A good mentor of mine told me if you want to create a flying car, then start with making some wheels into a skateboard, enjoy the skateboard and turn that into a bike and so on.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Learning to code is super easy — said no one ever. Learning to code can certainly be a daunting task to many, but one of the most helpful ways to learn and stay engaged it is to start small. What this means is that you should first learn the basic syntax of the language, then start writing some code to practice. Once you’ve gotten a hang of it, go ahead and pat yourself on the back!&lt;br&gt;
​&lt;br&gt;
Take things one at a time so that you are focused on mastering bits of information or concepts. As you stack up those building blocks and celebrate those small wins, take a step back and you’ll see that you’re really onto something.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Build a personal low-risk project that tackles a new idea or puts a new twist on an old idea&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Learning to code gives you the tools to build things that can potentially change the world. Build things, test what you’ve learned, and keep going at it. There are many resources available online to help inspire you, or, you can even join events like hackathons. Having a project, whether it’s all to yourself or with some friends, can be a great way to keep your drive. If you're stuck on what side project ideas, &lt;a href="https://www.codementor.io/npostolovski/40-side-project-ideas-for-software-engineers-g8xckyxef"&gt;here's 40&lt;/a&gt; to choose from.&lt;br&gt;
​&lt;/p&gt;

&lt;h2&gt;
  
  
  3. Get a mentor
&lt;/h2&gt;

&lt;blockquote&gt;
&lt;p&gt;Get training or regular mentoring by an expert in the language of choice or technology you aspire to master &lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Most developers can probably tell you how much they’ve gained when learning from a mentor, whether it’s a senior colleague or even an acquaintance in the field. Having a mentor means avoiding those common mistakes and roadblocks that slow down your learning process. Mentors have all “been there, done that” and can provide invaluable advice and motivation taken from their real-world experience.&lt;br&gt;
​&lt;br&gt;
After finding that mentor, the possibilities for you to grow as a developer are endless. Make the most of your mentorship through &lt;a href="https://www.codementor.io/pair-programming"&gt;pair programming&lt;/a&gt;, mock interviews, or even get a referral. Mentors are, without a doubt, the most reliable motivators that will guide you to the finish line.&lt;br&gt;
​&lt;/p&gt;

&lt;h2&gt;
  
  
  4. Maintain a Portfolio
&lt;/h2&gt;

&lt;p&gt;Once you’ve built more and more things, don't forget to keep a collection of your work. Whenever you’re feeling lack of motivation, you can always refer to this and see how far you’ve come. If you’re not quite sure what you should include in your portfolio, here's &lt;a href="https://dev.to/emmawedekind/how-to-build-a-great-technical-portfolio-53bb"&gt;how to build a great tech portfolio&lt;/a&gt; and &lt;a href="https://www.codementor.io/learn-programming/12-important-things-to-include-in-web-dev-portfolios"&gt;here’s a list&lt;/a&gt; of the most important things to include. &lt;/p&gt;

&lt;p&gt;Don’t just maintain a portfolio for the purposes of finding a job though, you should be proud of what you’ve accomplished so far!&lt;br&gt;
​&lt;/p&gt;

&lt;h2&gt;
  
  
  5. Just do it. Or just do nothing.
&lt;/h2&gt;

&lt;blockquote&gt;
&lt;p&gt;I try to keep in mind that the shortest distance between me and my goal is just to do the damn thing.  &lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Sometimes, you just have to stop over-thinking and over-complicating things and just do it.&lt;br&gt;
​&lt;br&gt;
On the other hand, you can just “Do nothing about it. That’s right, forget about whatever is bothering you”.&lt;br&gt;
​&lt;br&gt;
Keep in mind that it’s easy to burnout after a few hours of binge-watching tutorials or non-stop programming. It’s important that you allocate some time for getting rest in order to recover, recharge, and reset. &lt;/p&gt;

&lt;p&gt;And who knows, maybe you’ll even be able to solve the issue in your dreams! (Seriously though, it happens.)&lt;br&gt;
​&lt;/p&gt;

&lt;h2&gt;
  
  
  6. Keep a good balance
&lt;/h2&gt;

&lt;p&gt;​It can be easy to forget that there’s a world outside of your computer, so make sure that you’re consistently taking a break &lt;em&gt;away&lt;/em&gt; from your computer (or even from electronics for that matter). Spending a ton of time on the same issue without making progress can easily lead to frustration, stress, and eventually, a burnout. Instead, meet up with your best buddies, spend some time with your family, or anything to get your mind off of whatever you’re working on, even if it’s for a few hours. Your brain will thank you for it.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Programming is a very introverted activity, so getting enough human contact can also be a challenge, especially for those people, like me, who were drawn to programming because they are themselves introverts. Making sure that I get enough social contact has been a challenge, so I started taking acting and improv classes.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  7. Be a part of a supportive community
&lt;/h2&gt;

&lt;p&gt;No matter what programming language you're learning, there's probably an online community out there for you. There, you can connect with your peers or developers more experienced than you that have been in your shoes before.&lt;/p&gt;

&lt;p&gt;For beginners, I'd recommend &lt;a href="https://www.codenewbie.org/"&gt;CodeNewbie&lt;/a&gt; and &lt;a href="https://www.freecodecamp.org/"&gt;freeCodeCamp&lt;/a&gt; are great places to start. There's also female-oriented communities such as &lt;a href="http://ladieslearningcode.com/"&gt;Ladies Learning Code&lt;/a&gt;.&lt;br&gt;
​&lt;br&gt;
Lastly, there’s always Reddit (e.g. &lt;a href="https://www.reddit.com/r/learnprogramming"&gt;r/learnprogramming/&lt;/a&gt;), with subreddits for practically every programming language.&lt;br&gt;
​&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;I hope these tips will help you maintain your motivation for programming, and maybe even help you motivate your peers. You can do it! 💪🏻&lt;/p&gt;

&lt;p&gt;A special thanks to Rick van Hattem, Yad Faeq, Andy Maleh, Matthew Johnson, Marcos Rodriguez, and Christoph Wagner for providing awesome quotes.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;This post has been updated and was originally published here: &lt;a href="https://www.codementor.io/codementorteam/7-secrets-to-staying-motivated-when-learning-to-code-a2dy7hqar"&gt;https://www.codementor.io/codementorteam/7-secrets-to-staying-motivated-when-learning-to-code-a2dy7hqar&lt;/a&gt;&lt;/em&gt;&lt;/p&gt;




&lt;p&gt;How do you stay motivated? Is there anything that works or doesn't work for you? Let me know below!&lt;/p&gt;

</description>
      <category>beginners</category>
      <category>motivation</category>
      <category>career</category>
      <category>productivity</category>
    </item>
  </channel>
</rss>
