<?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>DEV Community: Kyle Williams</title>
    <description>The latest articles on DEV Community by Kyle Williams (@kylewcode).</description>
    <link>https://dev.to/kylewcode</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%2F532726%2F08ca5059-d49e-4ff8-bd33-7b0a625e9841.jpeg</url>
      <title>DEV Community: Kyle Williams</title>
      <link>https://dev.to/kylewcode</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/kylewcode"/>
    <language>en</language>
    <item>
      <title>How To Efficiently Update React State For Multiple DOM Inputs Using the useReducer() Hook</title>
      <dc:creator>Kyle Williams</dc:creator>
      <pubDate>Sun, 21 Nov 2021 12:48:41 +0000</pubDate>
      <link>https://dev.to/kylewcode/how-to-efficiently-update-react-state-for-multiple-dom-inputs-using-the-usereducer-hook-2e8d</link>
      <guid>https://dev.to/kylewcode/how-to-efficiently-update-react-state-for-multiple-dom-inputs-using-the-usereducer-hook-2e8d</guid>
      <description>&lt;p&gt;This article assumes some basic familiarity with the &lt;code&gt;useReducer()&lt;/code&gt; hook. Examples are using &lt;code&gt;react-bootstrap&lt;/code&gt; but you don't need to be using it in your own project for this to work.&lt;/p&gt;

&lt;h1&gt;
  
  
  Efficient VS Inefficient
&lt;/h1&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%2Fuploads%2Farticles%2Fvkbvqdtwsrbtmmmu0vyp.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%2Fuploads%2Farticles%2Fvkbvqdtwsrbtmmmu0vyp.png" alt="HTML form with inputs for name and address"&gt;&lt;/a&gt;&lt;br&gt;
Any DOM structure of HTML inputs would do, but let's say for example you have an HTML form such as the one above. You want React to update state for every change of the input by the user.&lt;/p&gt;
&lt;h2&gt;
  
  
  Inefficient
&lt;/h2&gt;

&lt;p&gt;Assuming this state object...&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;  const initState = {
    firstName: "",
    lastName: "",
    street: "",
    aptSuite: "",
    city: "",
    stateName: "",
    zipcode: "",
    date: "",
    title: "",
    status: "fillingOutForm",
  };
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Assuming a form input element structured like this...&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;Form.Label htmlFor="user-first-name"&amp;gt;First name&amp;lt;/Form.Label&amp;gt;
  &amp;lt;Form.Control
    type="text"
    name="FIRSTNAME" // Used for the action type
    id="user-first-name"
    value={formState.firstName} // formState from useReducer
    required
    onChange={(e) =&amp;gt; {
      const name = e.target.name;
      const value = e.target.value;
      dispatch({type: "CHANGE_" + name, payload: value });
    }}
/&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You could have a separate action type within the reducer function for each DOM input such as...&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;switch (type) {
  case CHANGE_FIRSTNAME:
    // Return modified state.
  case CHANGE_LASTNAME:
    // Return modified state.
  case CHANGE_STREET:
    // Return modified state.
  default:
    return state;
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This is inefficient however.&lt;/p&gt;

&lt;h2&gt;
  
  
  Efficient
&lt;/h2&gt;

&lt;p&gt;The solution to this inefficiency is to abstract outwards in the reducer function.&lt;/p&gt;

&lt;p&gt;Given this &lt;code&gt;onChange&lt;/code&gt; handler...&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// For example, the DOM input attribute name is 'firstName'
onChange={(e) =&amp;gt; {
  const field = e.target.name;
  const value = e.target.value;

  dispatch({
    type: "CHANGE_INPUT",
    payload: {
      value,
      field,
    },
  });
}}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;...the reducer function could contain this...&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;  function formReducer(state, action) {
    const { type, payload } = action;

    switch (type) {
      case "CHANGE_INPUT":
        return { ...state, [payload.field]: payload.value };
      default:
        return state;
    }
  }
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;em&gt;Normally one would have more cases in the reducer function but this example is simplified for educational purposes&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;In the code above, a computed property name is used to take the attribute name of the element ('firstName') and update state in the right place. In this case...&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const initState = {
  firstName: "Whatever was type in by user",
  // Rest of state properties...
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h1&gt;
  
  
  Gotchas
&lt;/h1&gt;

&lt;p&gt;Remember how to access the data needed using computed property names. You need to wrap the dot notation object accessor for the action payload object in &lt;strong&gt;brackets&lt;/strong&gt;.&lt;br&gt;
&lt;code&gt;return { ...state, [payload.field]: payload.value };&lt;/code&gt;&lt;/p&gt;
&lt;h1&gt;
  
  
  Further Cleaning
&lt;/h1&gt;

&lt;p&gt;Optimization of code length can be achieved by moving code from the &lt;code&gt;onChange()&lt;/code&gt; handler to its own function. It might even be more descriptive to change the name to something like &lt;code&gt;updateStateWithInputValue&lt;/code&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const changeDOMInput = (e) =&amp;gt; {
  const field = e.target.name;
  const value = e.target.value;
  dispatch({
    type: "CHANGE_INPUT",
    payload: {
      value,
      field,
    },
  });
};

onChange={(e) =&amp;gt; {
  changeDOMInput(e);
}}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;I hope this helps!&lt;/p&gt;

&lt;h1&gt;
  
  
  Connect With Me!
&lt;/h1&gt;

&lt;p&gt;&lt;a href="https://www.kylewcode.com/" rel="noopener noreferrer"&gt;www.kylewcode.com&lt;/a&gt;&lt;br&gt;
&lt;a href="https://twitter.com/kylewcode" rel="noopener noreferrer"&gt;Twitter&lt;/a&gt;&lt;br&gt;
&lt;a href="https://www.linkedin.com/in/85kylewilliams/" rel="noopener noreferrer"&gt;LinkedIn&lt;/a&gt;&lt;br&gt;
&lt;a href="https://github.com/kylewcode" rel="noopener noreferrer"&gt;GitHub&lt;/a&gt;&lt;/p&gt;

</description>
      <category>react</category>
      <category>javascript</category>
      <category>webdev</category>
    </item>
    <item>
      <title>The Watch and Code Intro Part Is Unlike Any Other Programming Course I've Taken</title>
      <dc:creator>Kyle Williams</dc:creator>
      <pubDate>Sun, 07 Mar 2021 17:21:04 +0000</pubDate>
      <link>https://dev.to/kylewcode/the-watch-and-code-intro-part-is-unlike-any-other-programming-course-i-ve-taken-2nn9</link>
      <guid>https://dev.to/kylewcode/the-watch-and-code-intro-part-is-unlike-any-other-programming-course-i-ve-taken-2nn9</guid>
      <description>&lt;p&gt;While most courses I've taken focus on the specifics of using a particular tool in programming, the introductory portion of &lt;a href="https://watchandcode.com/"&gt;Watch and Code&lt;/a&gt; made by &lt;a href="https://twitter.com/gordon_zhu"&gt;Gordon Zhu&lt;/a&gt; is a course that covers the high level programming concepts such as how to approach coding problems, checking expectations versus reality, and utilizing available resources to solve problems before going to someone else to ask.&lt;/p&gt;

&lt;p&gt;Here are the core elements that I felt were most beneficial for me.&lt;/p&gt;

&lt;h2&gt;
  
  
  The Meta-Skill of Problem Solving
&lt;/h2&gt;

&lt;p&gt;In it's most simplistic state this means to clearly define a problem, list possible solutions, and compare the tradeoffs of each solution.&lt;/p&gt;

&lt;h2&gt;
  
  
  Using the Debugger
&lt;/h2&gt;

&lt;p&gt;I think there are likely other courses on using the debugger. This one happened to be my first introduction for really focusing on this tool. Remembering to use the debugger has proven to be useful in reducing the amount of time between encountering and overcoming a problem.&lt;/p&gt;

&lt;h2&gt;
  
  
  Autonomy
&lt;/h2&gt;

&lt;p&gt;I often find myself spending a long amount of time trying to figure out something on my own. I believe I should have a balance between this and seeking help. Gordon emphasizes spending time with available documentation resources before reaching out to ask someone what the answer is. Although this is much slower at first, I believe it would better develop the meta-skill of problem solving than someone who too often encounters a problem and asks for help soon.&lt;/p&gt;

&lt;p&gt;Given that documentation is not always helpful, I still will look at documentation first whether MDN or the specific documentation for a tool such as React or testing-library.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://twitter.com/gordon_zhu/status/1313594741288648704?ref_src=twsrc%5Etfw%7Ctwcamp%5Etweetembed%7Ctwterm%5E1313594741288648704%7Ctwgr%5E%7Ctwcon%5Es1_c10&amp;amp;ref_url=https%3A%2F%2Fpublish.twitter.com%2F%3Fquery%3Dhttps3A2F2Ftwitter.com2Fgordon_zhu2Fstatus2F1313594741288648704widget%3DTweet"&gt;This is a particularly insightful tweet&lt;/a&gt; Gordon made about being more independent in seeking a solution.&lt;/p&gt;

&lt;h2&gt;
  
  
  Expectations vs Reality
&lt;/h2&gt;

&lt;p&gt;This was a fresh concept for me. Basically he walked me through the process of writing comments in code that outlined what I expected the code to do. Then after running the debugger or code, I would note the reality of what actually occurred.&lt;/p&gt;

&lt;p&gt;The idea is that as a beginner, my expectations will less often match up with reality than someone who is more experienced.&lt;/p&gt;

&lt;p&gt;What I also thought was unique was that he would assign percentages to the probability of his expectations being true or false. For example, &lt;/p&gt;

&lt;h3&gt;
  
  
  Expectation
&lt;/h3&gt;

&lt;p&gt;The variable x will equal number 140. 90% True &lt;/p&gt;

&lt;h3&gt;
  
  
  Reality
&lt;/h3&gt;

&lt;p&gt;The variable x equals a string '140'.&lt;/p&gt;

&lt;p&gt;In this case I was very sure about my expectations being correct and they weren't! So what does this say about how I came to my expectation? This then opens a path to deep learning. I mean to learn how to evolve my thinking to close the gap between my expectations of code behavior and reality.&lt;/p&gt;

&lt;h2&gt;
  
  
  Slow is Fast
&lt;/h2&gt;

&lt;p&gt;I don't always want to slow down and follow these other concepts. There's a feeling of anxiety that I've got to get somewhere now. This mentality is a problem. Because as trite as it sounds, "Haste makes waste." It's seems a spiritual concept in the sense that one can go slow in order to go fast. &lt;/p&gt;

&lt;p&gt;We don't live in a society that supports slow, deliberate thinking and action. In a way, Watch and Code is encouraging a more thoughtful approach to programming that is more involved in the process rather than results.&lt;/p&gt;

</description>
      <category>programming</category>
      <category>codenewbie</category>
    </item>
    <item>
      <title>Setting Up Custom Environment Variables Using dotenv and Node-config</title>
      <dc:creator>Kyle Williams</dc:creator>
      <pubDate>Fri, 22 Jan 2021 19:32:54 +0000</pubDate>
      <link>https://dev.to/kylewcode/setting-up-custom-environment-variables-using-dotenv-and-node-config-24hg</link>
      <guid>https://dev.to/kylewcode/setting-up-custom-environment-variables-using-dotenv-and-node-config-24hg</guid>
      <description>&lt;h2&gt;
  
  
  The Problem
&lt;/h2&gt;

&lt;p&gt;Mistakes are a great way to learn. Working on &lt;a href="https://www.udemy.com/course/mern-stack-front-to-back/" rel="noopener noreferrer"&gt;Brad Traversy's MERN Front to Back course&lt;/a&gt;, I wanted to 'green up' my git contributions graph so I decided I would commit after completing each lesson. &lt;/p&gt;

&lt;p&gt;Since it was a tutorial I wasn't worried about any consequences. Shortly after I got an email from a service called GitGuardian about the vulnerability of exposing my database password inside my MongoDB URI because I committed it to GitHub. Now the login credentials are exposed to the world.&lt;/p&gt;

&lt;p&gt;I wasn't worried about it because it's a junk database, and believed I would learn how to protect keys and passwords along the journey. It's still important to practice as if it's the real thing.&lt;/p&gt;

&lt;p&gt;So as part of good practice, I threw the situation out on Slack for comment by the local &lt;a href="https://orlandodevs.com/" rel="noopener noreferrer"&gt;Orlando DEVS&lt;/a&gt; community.&lt;/p&gt;

&lt;p&gt;Some documentation searching later, I was led to the solution.&lt;/p&gt;

&lt;h2&gt;
  
  
  The Solution
&lt;/h2&gt;

&lt;p&gt;The solution was to store the user database password in an environment variable. For the MERN course, &lt;code&gt;config&lt;/code&gt; was already being used provide access to the URI, but it uses a &lt;code&gt;config/default.json&lt;/code&gt; file. Being a JSON file meant that I couldn't access &lt;code&gt;process.env&lt;/code&gt; because it's a data interchange format and not a file for storing code instructions.&lt;/p&gt;

&lt;p&gt;Now onto how it's done.&lt;/p&gt;

&lt;h3&gt;
  
  
  Set up dotenv
&lt;/h3&gt;

&lt;p&gt;If you don't have &lt;code&gt;dotenv&lt;/code&gt; installed, you can &lt;a href="https://www.npmjs.com/package/dotenv" rel="noopener noreferrer"&gt;get it here&lt;/a&gt;. &lt;/p&gt;

&lt;p&gt;If you want to only require &lt;code&gt;dotenv&lt;/code&gt; on local setups then you need to encapsulate the require function inside a conditional that checks if your app is not in production mode.&lt;/p&gt;

&lt;p&gt;For me this was done within &lt;code&gt;server.js&lt;/code&gt;.&lt;br&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%2Fsf2tjq3u7z9iulikrwwo.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%2Fsf2tjq3u7z9iulikrwwo.png" alt="carbon"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Add the environment variable
&lt;/h3&gt;

&lt;p&gt;When I had used environment variables before I was interpolating them inside a url on the front-end. This time I pasted the entire thing, a database URI in this case, inside the &lt;code&gt;.env&lt;/code&gt; file.&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%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fa5f5c9ut7g5yvj5caf2f.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%2Fa5f5c9ut7g5yvj5caf2f.png" alt="carbon (1)"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h4&gt;
  
  
  Note
&lt;/h4&gt;

&lt;p&gt;&lt;em&gt;As I'm writing this I have yet to complete the course. I was curious about how Brad approaches keeping these environment variables from making it into the build (I know this happens in React).&lt;/em&gt; &lt;/p&gt;

&lt;p&gt;&lt;em&gt;After skipping ahead in the course, it turns out he creates a separate &lt;code&gt;config/production.json&lt;/code&gt; for production including a separate database (though I think he skips that for the course). Plus deployment is to Heroku, so I'm sure I'll have the opportunity to learn how that plays into keep these sensitive variables a secret.&lt;/em&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Prevent .env from being committed
&lt;/h3&gt;

&lt;p&gt;Last step here is to add &lt;code&gt;.env&lt;/code&gt; to &lt;code&gt;.gitignore&lt;/code&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  Set up config
&lt;/h3&gt;

&lt;p&gt;If you need it, grab &lt;code&gt;config&lt;/code&gt; &lt;a href="https://www.npmjs.com/package/config" rel="noopener noreferrer"&gt;here&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;For the MERN course it's instructed to have a &lt;code&gt;config/default.json&lt;/code&gt; where the MongoDB URI is stored. With the problem of not being able to access &lt;code&gt;process.env&lt;/code&gt; inside it, that led me to custom environment variables via &lt;code&gt;config&lt;/code&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  Create custom config
&lt;/h3&gt;

&lt;p&gt;Create a &lt;code&gt;custom-environment-variables.json&lt;/code&gt; file inside the &lt;code&gt;config&lt;/code&gt; folder. Paste the variable as a string into the JSON value field for the key. Then you'll be able to access it from your code via &lt;code&gt;const db = config.get('mongoURI');&lt;/code&gt;&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;

{
    "mongoURI": "DB_ACCESS_KYLE123"
}


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Note: Custom environment variables take precedence over all other configuration files and will overwrite them. Only command line options can take top precedence.&lt;/p&gt;

&lt;p&gt;Hopefully this has been helpful to you in either working with the MERN course or in your own personal or company project.&lt;/p&gt;

&lt;p&gt;Thanks for reading!&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;a href="https://www.kylewcode.com" rel="noopener noreferrer"&gt;www.kylewcode.com&lt;/a&gt;&lt;br&gt;
&lt;a href="https://twitter.com/kylewcode" rel="noopener noreferrer"&gt;Reach out to me on Twitter @kylewcode&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;

</description>
      <category>javascript</category>
      <category>node</category>
    </item>
    <item>
      <title>2020 Retrospective: What I'll Keep Doing &amp; What I'll Change</title>
      <dc:creator>Kyle Williams</dc:creator>
      <pubDate>Sun, 10 Jan 2021 17:29:18 +0000</pubDate>
      <link>https://dev.to/kylewcode/2020-retrospective-what-i-ll-keep-doing-what-i-ll-change-19ep</link>
      <guid>https://dev.to/kylewcode/2020-retrospective-what-i-ll-keep-doing-what-i-ll-change-19ep</guid>
      <description>&lt;p&gt;Since I started my programming journey in November of 2019, the bulk of my time learning was spent in 2020. I've been blessed to have avoided certain hardships from the pandemic and for that I'm grateful. &lt;/p&gt;

&lt;p&gt;So naturally this really aided the process of learning programming in as relaxed manner as possible. As always, when looking back I can always have judgements about what I did well, what I did poorly, and everything in between.&lt;/p&gt;

&lt;h2&gt;
  
  
  What I'll Keep Doing
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Being active in my community's Slack channel
&lt;/h3&gt;

&lt;p&gt;By far this has been part of the 20% that gives 80% of assistance for my learning. Specifically this is the Orlando Devs (ODevs) Slack channel. I am very grateful for the time people have put into responding to my posts.&lt;/p&gt;

&lt;h3&gt;
  
  
  Calling my mentor around once a month
&lt;/h3&gt;

&lt;p&gt;For any big decision, such as what programming path, framework, or language to learn, I run it through my mentor. I can get dozens of opinions from ODevs, but it's really essential to give more weight to one individual's advice, not because it's going to be correct but because it prevents hesitation and doubt. Hesitation and doubt increases stress levels and inhibits learning. For myself, it's better to act sooner than later than to bounce around in uncertainty.&lt;/p&gt;

&lt;h3&gt;
  
  
  Listening to TechJR
&lt;/h3&gt;

&lt;p&gt;I find this podcast interesting because most other podcasts I listen to have been around for a while and are run by people who have generally been in their industry for a long time. Here I can hear a perspective that's a bit more relatable since the hosts have only been developers for over two years (at the time of this post).&lt;/p&gt;

&lt;h3&gt;
  
  
  Listening to Douglas Crockford
&lt;/h3&gt;

&lt;p&gt;My mentor recommended I listen to Douglas Crockford mainly, in my opinion, because he's opinionated and older. I appreciate his candor and the larger perspective he has because of how long he has been around. Particularly I connect with his statement that programmers are emotional just like everyone else and don't necessarily make decisions based in logic. He often cites the slowness of innovation in software for this. To paraphrase him, "We have to wait for the older generation to die off to get adoption of newer, good ideas."&lt;/p&gt;

&lt;h3&gt;
  
  
  Maintaining a goal document in Evernote
&lt;/h3&gt;

&lt;p&gt;I have a goal to obtain employment as a front-end React developer. I keep a document in Evernote where, with help from my mentor and one other ODev member &lt;a href="https://dev.to/vincentntang"&gt;Vincent Tang&lt;/a&gt;, the steps to get there are laid out in order. It's essential to have some kind of plan. The reality is that my plan changed a lot and therefore this document needed to be modified.&lt;/p&gt;

&lt;h3&gt;
  
  
  Organizing projects in Workflowy
&lt;/h3&gt;

&lt;p&gt;I really like this app. It makes it really easy to go on tangents and drill down into whatever specific point I might be at. I use it to organize the TODO list for an application as well as writing pseudocode. It's so easy. When I encounter a problem I go down another level and split the problem into two more bullet points named PROBLEM and SOLUTION.&lt;/p&gt;

&lt;h3&gt;
  
  
  Work 25 minute spurts with 5 minute breaks
&lt;/h3&gt;

&lt;p&gt;I work in 25 minute spurts because I think it's more effective for long term productivity but also so I can give my eyes a break (I have myopia).&lt;/p&gt;

&lt;h3&gt;
  
  
  Scheduling tweets to buffer
&lt;/h3&gt;

&lt;p&gt;This makes it really convenient to come up with some things to say on Twitter in an hour or two sitting and have them queued up for weeks.&lt;/p&gt;

&lt;h3&gt;
  
  
  Keeping an engineering daybook
&lt;/h3&gt;

&lt;p&gt;I got this idea from a &lt;a href="https://dev.to/germangamboa95/engineering-daybook-d6p"&gt;post&lt;/a&gt; here by &lt;a href="https://dev.to/germangamboa95"&gt;German Gamboa&lt;/a&gt;. Basically you write down something you learned in the day of programming. I keep it to things that are not 'too' mundane. Think of it as a journal of TIL (Today I Learned).&lt;/p&gt;

&lt;h2&gt;
  
  
  What I'll change
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Commenting frequently on Twitter
&lt;/h3&gt;

&lt;p&gt;I'm not a fan of social media, but Twitter is a busy spot for conversations around development. I understand the necessity of getting involved in the conversation. For me though, my focus is to be really clear on why I'm on Twitter and not move my attention to topics that are distracting or inciteful. So the goal is to be more active in commenting on other conversations. The main point is daily.&lt;/p&gt;

&lt;h3&gt;
  
  
  Not working past the point of my head hurting
&lt;/h3&gt;

&lt;p&gt;I'm not very good at this. Since I put an arbitrary number on hours per day I want to study, which isn't necessarily a bad thing, I tend to push on even when I could lie down for a bit.&lt;/p&gt;

&lt;h3&gt;
  
  
  Not considering a lot of advice/opinions
&lt;/h3&gt;

&lt;p&gt;Since I follow the self-taught path, one of the biggest traps is considering too much advice. I notice I'm in this trap when I start to have feelings of frustration and confusion. I have to exercise the courage to cut-off additional information and realize it's not going to matter in the long game.&lt;/p&gt;

&lt;h3&gt;
  
  
  Not going to bed earlier
&lt;/h3&gt;

&lt;p&gt;I've already been a big stickler on sleep. The difference in my cognitive abilities, heck...everything, between the days I sleep well and don't is huge. If I could optimize anything right now it would be to get the best sleep possible. I have to wake at 4am for my day job so my bedtime is 8pm which I usually hit the sack at 8:15-8:30pm. Last night I crawled in at 7:20 and slept great, so probably doing that more might help. Overall I think I'm still too dumb to realize the false economy in programming while fatigued.&lt;/p&gt;

&lt;h3&gt;
  
  
  Not focusing on personal projects
&lt;/h3&gt;

&lt;p&gt;I've spent a good bit of time on tutorials, algorithm challenges, etc in 2020. For 2021, after I finish some courses on React, I plan on spending the majority of time creating projects to go on my resume.&lt;/p&gt;

&lt;p&gt;And that's it! Let me know in the comments below 3 things you will keep doing and 3 that you'll change. Good luck in 2021!&lt;/p&gt;

</description>
    </item>
    <item>
      <title>20 Lessons I Learned From Creating My First React App</title>
      <dc:creator>Kyle Williams</dc:creator>
      <pubDate>Fri, 04 Dec 2020 21:38:58 +0000</pubDate>
      <link>https://dev.to/kylewcode/20-lessons-i-learned-from-creating-my-first-react-app-42k8</link>
      <guid>https://dev.to/kylewcode/20-lessons-i-learned-from-creating-my-first-react-app-42k8</guid>
      <description>&lt;p&gt;&lt;em&gt;Before I begin I just want to make it clear that what I write may not be true and only be applicable to myself based off my personality, background, temperament, attitude, etc.&lt;/em&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Lesson 1: Web development is complicated, so be ready to get confused.
&lt;/h2&gt;

&lt;blockquote&gt;
&lt;p&gt;Complexity creates confusion - (paraphrased) Douglas Crockford&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;There is a lot to learn and being self-taught means that the most important decision to make is "What should I learn/focus on next?" &lt;/p&gt;

&lt;p&gt;Documentation isn't enough because I've noticed that authors have to assert some level of prior knowledge on account of the reader. I heard Douglas Crockford say something along the lines of "Complexity creates confusion.", and web development is complex. It's the most complex thing I've endeavored to learn, which leads me to the next lesson...&lt;/p&gt;

&lt;h2&gt;
  
  
  Lesson 2: A mentor helps a lot.
&lt;/h2&gt;

&lt;p&gt;One of my favorite books is &lt;a href="https://www.amazon.com/Mastery-Robert-Greene/dp/014312417X"&gt;Mastery&lt;/a&gt; &lt;em&gt;by Robert Greene&lt;/em&gt; which illustrates a medieval apprenticeship model of learning that I prefer. &lt;/p&gt;

&lt;p&gt;Luckily I have a friend who is a senior developer who is willing to lend his advice. Because web development is complex, it's much easier to just say, "My goal is _____. What should I do next?" Otherwise it's easy for me to waste time anguishing over what path to take.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Note: I have no preferences on any specific tool, language, or path. My friend suggested front-end web development based off my prior arts/music background. Others may be different.&lt;/em&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Lesson 3: Don't get advice from too many people or sources.
&lt;/h2&gt;

&lt;p&gt;Again, complexity creates confusion. Confusion has a negative impact on learning and productivity. In my experience it's better for me to make decisions from limited information without dragging it out and learn to live with the outcomes.&lt;/p&gt;

&lt;p&gt;I may ask questions in huge forums, like Twitter, but I think it's better to limit the advice I consider.&lt;/p&gt;

&lt;h2&gt;
  
  
  Lesson 4: Don't spend too much time testing.
&lt;/h2&gt;

&lt;p&gt;Testing got pretty difficult when I started to look at mocking data from API calls. It did not seem simple. I got advice from &lt;a href="https://dev.to/vincentntang"&gt;Vincent Tang&lt;/a&gt; to not spend too much time with testing. Back to lesson 3, I didn't ping 15 other people. I just stopped with testing as I had already learned the basics of Jest.&lt;/p&gt;

&lt;h2&gt;
  
  
  Lesson 5: Having so many different tools makes it easier to seek a solution in the wrong document.
&lt;/h2&gt;

&lt;p&gt;Using &lt;code&gt;create-react-app&lt;/code&gt; as a beginner, having made no React app prior, meant that I wast starting out with more tools. For example there is React.js, &lt;code&gt;create-react-app&lt;/code&gt;, &lt;code&gt;testing-library&lt;/code&gt;, &lt;code&gt;jest-dom&lt;/code&gt;, and Heroku for my deployment. They all have documentation on certain aspects of development. &lt;/p&gt;

&lt;p&gt;More importantly, I had no prior-experience with any of these tools.&lt;/p&gt;

&lt;p&gt;For example, I found myself looking up deployment details on Heroku for Node.js apps. Later I learned there was different information from the &lt;code&gt;create-react-app&lt;/code&gt; developer documents about deploying specifically to Heroku.&lt;/p&gt;

&lt;p&gt;This caused confusion for me. The app seemed to build okay following Heroku's docs, but it wasn't clear which way was better or if it even mattered.&lt;/p&gt;

&lt;h2&gt;
  
  
  Lesson 6: Headaches are a sign I'm in over my head.
&lt;/h2&gt;

&lt;p&gt;Jest's documentation on mocks was painful for me to read. I found myself not having the necessary prior knowledge to understand them. &lt;/p&gt;

&lt;p&gt;I felt irritation, frustration, and pressure in my skull. This is not a good mental state for learning and waste of time. This is part of the reason I took a step away from testing.&lt;/p&gt;

&lt;h2&gt;
  
  
  Lesson 7: Programming &lt;em&gt;-ahem-&lt;/em&gt; informs me if I am not clear on some prior foundational concept.
&lt;/h2&gt;

&lt;p&gt;This is related to lesson 6. Bugs and sore eyes are the result. Time to move a level down.&lt;/p&gt;

&lt;h2&gt;
  
  
  Lesson 8: Sometimes the hardest decision is what to do.
&lt;/h2&gt;

&lt;p&gt;I think I'm repeating myself? Web development is complex. It's important to me to know when to cut myself off from considering options and move forward.&lt;/p&gt;

&lt;p&gt;My mentor suggested I just go to the school of hard knocks. There is nothing wrong with making mistakes. It's how I learn. &lt;br&gt;
 "Not doing that again. Jeez."&lt;/p&gt;

&lt;h2&gt;
  
  
  Lesson 9: It's easy to get lost in details and forget the big picture.
&lt;/h2&gt;

&lt;p&gt;100% this being my main weakness. This is why feedback is critical for me. I have to tell someone what I am doing.&lt;/p&gt;

&lt;h2&gt;
  
  
  Lesson 10: People are capable of change.
&lt;/h2&gt;

&lt;p&gt;By default I'm very methodical in learning and doing things. As I've become less afraid of failure, I'm noticing that with learning web development I'm a bit more 'jump right in' than I've typically been in the past.&lt;/p&gt;

&lt;h2&gt;
  
  
  Lesson 11: Don't run &lt;code&gt;npm init&lt;/code&gt; with &lt;code&gt;create-react-app&lt;/code&gt;.
&lt;/h2&gt;

&lt;p&gt;This added entries to &lt;code&gt;package.json&lt;/code&gt; that broke &lt;code&gt;\%PUBLIC_URL%\&lt;/code&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Lesson 12: Consider leaving configuration alone.
&lt;/h2&gt;

&lt;p&gt;I tried following the install instructions for &lt;code&gt;eslint&lt;/code&gt; configurations of &lt;code&gt;react-testing-library&lt;/code&gt; and &lt;code&gt;jest-dom&lt;/code&gt;. I just broke stuff and things didn't work. &lt;a href="https://twitter.com/DavidKPiano"&gt;David K Piano&lt;/a&gt; suggested I leave the configs alone. That made things simpler and easier, which I learned later is the purpose of &lt;code&gt;create-react-app&lt;/code&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Lesson 13: Check that the API serves over &lt;code&gt;https://&lt;/code&gt;.
&lt;/h2&gt;

&lt;p&gt;In the end I was unable to get my app fully functioning in deployment because of a "mixed content" error. I chose to drop an entire feature so I could finish and move on. Doh! This is what I'm talking about when I say "The harder the mistake, the better I remember."&lt;/p&gt;

&lt;h2&gt;
  
  
  Lesson 14: Having generalized project action steps would be great, thanks.
&lt;/h2&gt;

&lt;p&gt;This is again about being clear on next actions. I'll be spending some time researching and creating a general project checklist template with a focus on keeping it simple, ie. no complicated project management tools.&lt;/p&gt;

&lt;h2&gt;
  
  
  Lesson 16: Starting a project from the basis of a tutorial can result in not being able to do something important later on.
&lt;/h2&gt;

&lt;p&gt;I learned React first on FreeCodeCamp.com around the end of 2019. It teaches class components. My official decision to learn React is recent and someone suggested Kent C. Dodds' &lt;a href="https://egghead.io/courses/the-beginner-s-guide-to-react"&gt;free beginners Egghead.io course on React using function components and hooks&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;This course focused on CDN links to deliver &lt;code&gt;react&lt;/code&gt; and &lt;code&gt;react-dom&lt;/code&gt; with all of React happening in &lt;code&gt;index.html&lt;/code&gt; as a static web page. Even though in the end I did not figure out how to protect my API key I did run into the problem that I could not access &lt;code&gt;process.env&lt;/code&gt; within a static &lt;code&gt;html&lt;/code&gt; file.&lt;/p&gt;

&lt;h2&gt;
  
  
  Lesson 17: Mocking an API call is hard and beyond my level right now.
&lt;/h2&gt;

&lt;p&gt;There is a huge gap in my knowledge on how to make this work. My impression is that it has to do with understanding and manipulating back-end code. Knowing where I lack is a good thing because it tells me where to focus next.&lt;/p&gt;

&lt;h2&gt;
  
  
  Lesson 18: API integration may be good to be done before front-end code is built.
&lt;/h2&gt;

&lt;p&gt;It felt clunky to be figuring out API proxy servers and such after having already built the front-end.&lt;/p&gt;

&lt;h2&gt;
  
  
  Lesson 19: Protecting API keys is not a simple task in React...at least right now.
&lt;/h2&gt;

&lt;p&gt;Again, I think this has to do with my lack of knowledge in back-end coding since setting up a proxy server seems to be the solution.&lt;/p&gt;

&lt;h2&gt;
  
  
  Lesson 20: Creating a React app with a need-to-know strategy is okay.
&lt;/h2&gt;

&lt;p&gt;There are many ways to learn. My default for learning has been to follow courses and tutorials top to bottom. Sometimes for me (not speaking for others), doing courses and tutorials too much is a sign of a fear of failure or making mistakes.&lt;/p&gt;

&lt;p&gt;In this sense, learning piece-meal has been valuable on a personal level.&lt;/p&gt;

&lt;h2&gt;
  
  
  Thanks for reading!
&lt;/h2&gt;

&lt;p&gt;If you're interesting in giving me feedback on my project I'd greatly appreciate it. You will find a working version, minus the API feature, on the &lt;a href="https://codesandbox.io/s/vigilant-chaum-v892j"&gt;codesandbox&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>react</category>
      <category>javascript</category>
    </item>
  </channel>
</rss>
