<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[julias-guides - Medium]]></title>
        <description><![CDATA[A collection of guides, deep dives and resources related to web development. - Medium]]></description>
        <link>https://medium.com/jkmdev-walkthroughs?source=rss----1f80462cae17---4</link>
        <image>
            <url>https://cdn-images-1.medium.com/proxy/1*TGH72Nnw24QL3iV9IOm4VA.png</url>
            <title>julias-guides - Medium</title>
            <link>https://medium.com/jkmdev-walkthroughs?source=rss----1f80462cae17---4</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 23 Nov 2026 17:31:36 GMT</lastBuildDate>
        <atom:link href="https://medium.com/feed/jkmdev-walkthroughs" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[console.log(), but Fancier]]></title>
            <link>https://medium.com/jkmdev-walkthroughs/console-log-but-fancier-10fec931c44a?source=rss----1f80462cae17---4</link>
            <guid isPermaLink="false">https://medium.com/p/10fec931c44a</guid>
            <category><![CDATA[open-source]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[logging]]></category>
            <category><![CDATA[nodejs]]></category>
            <dc:creator><![CDATA[Julia McGeoghan]]></dc:creator>
            <pubDate>Fri, 01 Feb 2019 15:23:16 GMT</pubDate>
            <atom:updated>2019-02-01T15:23:16.568Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/685/1*pL6_-A_4638KFMNx9b_bHQ.png" /></figure><p>Recently I was writing a Node script for a project called <a href="https://github.com/Microsoft/fast-dna">fast-dna</a>, where messages were printed to the terminal based off the status of the script and what it was doing. However, initially I wasn’t making full use of what console had to offer. Until I got some <a href="https://github.com/Microsoft/fast-dna/pull/1340">feedback</a> from the project’s maintainers, I was creating the same sort of statements for any sort of message without taking advantage of more recent Javascript and Node features. Here I’ll go over what I learned when improving the formatting of these logs, as well as some additional info related to what I learned along the way.</p><h3>String Substitutions</h3><p>Your standard string formatting in Javascript might often look like the following:</p><p>console.log(name + &quot;&#39;s employee id is &quot; + is);</p><p>Another fairly common method:</p><p>console.log(“%s&#39;s employee id is %d”, name, id);</p><p>If you’ve used C this approach will be familiar to you, it uses printf style formatting. It’s a bit cleaner than the first example; you don’t need to separate and concatenate different portions of the string.</p><p>console.log(`${name} employee id is ${id}`);</p><p>An even better approach, using <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Template_literals">template literals</a>. This is a feature introduced in ES6, fundamentally enhancing what the Javascript language can do with strings. In addition to cleaner string substition it has expression interpolation.</p><pre>let carrotAmount = 2;<br>let onionAmount = 3;</pre><pre>console.log(`There are ${carrotAmount + onionAmount} veggies`);</pre><pre>// output: There are 5 veggies.</pre><p>and much more!</p><h3>Multi-Line Strings</h3><p>Using template literals for this can make writing multi-line code a lot cleaner. For example instead of:</p><pre>console.log(name + &quot;&#39;s employee id\n&quot; +<br>&quot;is &quot; + id + &quot;\n&quot;);</pre><p>You can do the same thing without the newlines or string concatenation.</p><pre>console.log(`${name}&#39;s employee id<br>is ${id}`);<br>// output:<br>// John&#39;s employee id<br>// is 2</pre><p>At first glance the above approach seems like a nice way to handle multi-line input in all cases, however when it’s nested in other blocks of code it becomes somewhat less workable…</p><pre>if (isValid) {<br>    console.log(`${name}&#39;s employee id<br>    is ${id}`); <br>}<br>// output:<br>// John&#39;s employee id<br>//    is 2</pre><p>As you can see, the spaces in front of the second line get included in the output. In this situation you can use certain packages to strip leading spaces/indents or compensate for other downfalls, <a href="https://github.com/declandewet/common-tags">common-tags</a> is a good example.</p><pre>import {stripIndents} from &#39;common-tags&#39;</pre><pre>if (isValid) {<br>    console.log(stripIndents`${name}&#39;s employee id<br>    is ${id}`);<br>}<br>// output:<br>// John&#39;s employee id<br>// is 2</pre><h3>Terminal Output with Colour</h3><p>At one point in my PR one of the maintainers asked about adding colour to my terminal output to make it easier to read. It makes a lot of sense; when you have multiple lines of text in the terminal, how can you determine what’s important? Using strong colours like red or green can be a good way to accent certain lines/messages.</p><h4>Ansi</h4><p>A simple approach is to use ansi codes. Below is an example of a console.log statement using them, as well as a breakdown of what’s going on.</p><p>console.log(&#39;\x1b[32m%s\x1b[0m&#39;, &#39;The files were successfully created!&#39;);</p><p>\x1b[32m = ansci colour code</p><p>%s = formatter, represents a string</p><p>\x1b[0m = clears the terminal</p><p>When we run our script with the above code, we’ll see it output the desired colour. If you want to view all the available colours to use click <a href="http://console.log(`The number of fruits I have are ${appleAmount + orangeAmount}`);">here</a>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/447/1*f5-D6t_MFw-yOgiluf-AOA.png" /></figure><h4>External Packages</h4><p>When using ansi codes you can’t easily tell what’s going on at first glance. For a better approach, you might want to consider external packages. For example, you could try using the <a href="https://github.com/chalk/chalk">chalk</a> package:</p><pre>const chalk = require(&#39;chalk&#39;);<br>console.log(chalk.red(&#39;Text in red&#39;));</pre><h3>Tables</h3><p>JSON objects with large data sets can get difficult to read. In some cases you might want to print select properties to the terminal so you can convey a targeted message.</p><pre>sampleJson.map(entry =&gt; {<br>    console.log(<br>        `firstname : ${entry.name.first}, ` +<br>        `lastname : ${entry.name.last}, ` +<br>        `balance: ${entry.balance}, ` + <br>        `company: ${entry.company}` <br>    );<br>});</pre><p>Will then output…</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/749/1*6fWclzAQlwr3WCqY9xv3BQ.png" /></figure><p>Which works fine on its own, but there are some other ways of approaching this. In these sort of situations, you might find it more useful to view this data in a table. Using the global console module you can do this easily.</p><pre>sampleJson.map(entry =&gt; {<br>    console.table([{<br>        firstname : entry.name.first,<br>        lastname : entry.name.last,<br>        balance: entry.balance,<br>        company: entry.company<br>    }]);<br>});</pre><p>Will then output…</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/603/1*z2l11jKxwXgNojql_PdhaA.png" /></figure><p>Having everything highlighted in green makes it easier to view certain properties and the table layout makes things easier to locate in general.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=10fec931c44a" width="1" height="1" alt=""><hr><p><a href="https://medium.com/jkmdev-walkthroughs/console-log-but-fancier-10fec931c44a">console.log(), but Fancier</a> was originally published in <a href="https://medium.com/jkmdev-walkthroughs">julias-guides</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[On Writing Platform Independent Node Scripts]]></title>
            <link>https://medium.com/jkmdev-walkthroughs/on-writing-platform-independent-node-scripts-2e11552eb674?source=rss----1f80462cae17---4</link>
            <guid isPermaLink="false">https://medium.com/p/2e11552eb674</guid>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[node]]></category>
            <category><![CDATA[open-source]]></category>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[path]]></category>
            <dc:creator><![CDATA[Julia McGeoghan]]></dc:creator>
            <pubDate>Fri, 01 Feb 2019 01:01:25 GMT</pubDate>
            <atom:updated>2019-02-01T15:26:04.265Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/480/0*vwwzh7hfQ_ZxQvFw.png" /></figure><p>One day you write a simple Node script that traverses the file system and copies all the files you need from A-Z to destination folder B. In a matter of seconds your new script will accomplish something that would have taken much longer, in a way that is less error prone.</p><p>You make a juicy PR containing your changes. However, when others try to run your script many immediately hit an error:</p><blockquote>Error: ENOENT: no such file or directory</blockquote><p>Yikes. Your primary development environment is Linux but other people are using Windows. You hard-coded the path to a file you wanted</p><p>path/to/file</p><p>…but this won’t be recognized by Windows because it doesn’t recognize those forward slashes. You consider using some sort of conditional statement to handle filepaths for these two types of systems, but that seems messy. And the reality is that you shouldn’t do that because there is, in fact, a much cleaner option.</p><h3>Node’s Path Module</h3><p>The Node path module is a core module that provides a set of functions/utilities that can be used to deal with filepaths. It is a very useful tool for cross-platform development and is great for open source projects, where different contributors are likely to use different systems.</p><h4>Windows vs. POSIX</h4><p>These are the two main file systems a developer will need to worry about when working with Node (both Mac and Linux use POSIX), and most of Path’s functions support both by default. There are a lot of useful utilities provided by this module and you might find it worthwhile to look through them all, but here I’ll cover a few I thought were especially noteworthy and relevant to this post.</p><h4><a href="https://nodejs.org/api/path.html#path_path_join_paths">path.join</a></h4><p>At first glance it might seem like this function simply joins filepath segments. However when reading through its documentation you’ll notice it mentions an extra benefit.</p><blockquote>The path.join() method joins all given path segments together using the <strong>platform-specific</strong> <strong>separator</strong> as a delimiter, then normalizes the resulting path.</blockquote><p>To avoid hard-coding slashes in filepaths and therefore introducing bugs, path.join should be used instead. This function will output a string with forward or backward slashes based on the system. For example:</p><pre>path.join(&#39;path&#39;, &#39;to&#39;, &#39;file&#39;);<br>// On Linux/Mac returns: &#39;path/to/file&#39;<br>// On Windows returns: &#39;path\to\file&#39;</pre><h4><a href="http://&/#39;/foo/bar/baz/asdf&#39;">path.sep</a></h4><p>What if you have a path, and want to create an array from each of its segments? For example, you do something like the following:</p><pre>&#39;path/to/file&#39;.split(&#39;/&#39;);<br>// Returns [&#39;path&#39;, &#39;to&#39;, &#39;file&#39;] on Linux/Mac</pre><p>If you write a function that searches for the / delimiter and creates an array based off that, it will create an error on Windows.</p><pre>&#39;path\\to\\file&#39;.split(&#39;/&#39;);<br>// Throws error on Windows</pre><p>To avoid this problem path.sep can be used. It isn’t a function, but a constant, and will be the path segment separator used by the corresponding system.</p><pre>&#39;path/to/file&#39;.split(path.sep); <br>// path.sep == &#39;/&#39;<br>// Returns[&#39;path&#39;, &#39;to&#39;, &#39;file&#39;] on Linux/Mac</pre><pre>&#39;path\\to\\file&#39;.split(path.sep); <br>// path.sep == &#39;\&#39;<br>// Returns [&#39;path&#39;, &#39;to&#39;, &#39;file&#39;] on Windows</pre><h4><a href="https://nodejs.org/api/path.html#path_path_delimiter">path.delimiter</a></h4><p>Like path.sep, path.delimiter provides a single constant value; on Windows this will be ; , on POSIX it’s :.</p><p>One place where you’ll likely see this sort of delimiter being used is in the PATH environment variable for your system. So if you ever need to parse that value, path.delimiter will be useful to you.</p><pre>process.env.PATH.split(path.delimiter);<br>// On POSIX returns [&#39;/usr/bin&#39;, &#39;/bin&#39;, &#39;/usr/sbin&#39;, &#39;/sbin&#39;, &#39;/usr/local/bin&#39;]<br>// On Windows returns [&#39;C:\\Windows\\system32&#39;, &#39;C:\\Windows&#39;, &#39;C:\\Program Files\\node\\&#39;]</pre><h4><strong>In Summary</strong></h4><p>When dealing with paths in your Javascript applications, use Node’s Path module to make filepaths platform agnostic. This is especially important when working in open source since you can’t guarantee that all contributors will be using a specific type of system.</p><h3>Further Reading</h3><ul><li><a href="https://shapeshed.com/writing-cross-platform-node/">https://shapeshed.com/writing-cross-platform-node/</a></li><li><a href="https://alan.norbauer.com/articles/cross-platform-nodejs/">https://alan.norbauer.com/articles/cross-platform-nodejs/</a></li><li><a href="https://gist.github.com/domenic/2790533#paths-and-urls">https://gist.github.com/domenic/2790533#paths-and-urls</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2e11552eb674" width="1" height="1" alt=""><hr><p><a href="https://medium.com/jkmdev-walkthroughs/on-writing-platform-independent-node-scripts-2e11552eb674">On Writing Platform Independent Node Scripts</a> was originally published in <a href="https://medium.com/jkmdev-walkthroughs">julias-guides</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Working with React and Typescript to create a Newsletter Subscription component]]></title>
            <link>https://medium.com/jkmdev-walkthroughs/working-with-react-and-typescript-to-create-a-newsletter-subscription-component-c9e0e5ab9c12?source=rss----1f80462cae17---4</link>
            <guid isPermaLink="false">https://medium.com/p/c9e0e5ab9c12</guid>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[typescript]]></category>
            <category><![CDATA[open-source]]></category>
            <category><![CDATA[mozilla]]></category>
            <category><![CDATA[react]]></category>
            <dc:creator><![CDATA[Julia McGeoghan]]></dc:creator>
            <pubDate>Sun, 16 Dec 2018 07:27:49 GMT</pubDate>
            <atom:updated>2018-12-11T05:02:39.252Z</atom:updated>
            <content:encoded><![CDATA[<h3>Common Voice</h3><p>I recently made a contribution to a Mozilla application called <a href="https://github.com/mozilla/voice-web">voice-web</a>. It’s an interface designed to collection speech donations for the <a href="https://voice.mozilla.org/en">Common Voice</a> project; an initiative to make voice recognition technology non-proprietary and open source.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*3GQBztf1Ch8o7eY3GURd4Q.png" /><figcaption>An image from the voice-web english homepage.</figcaption></figure><h4>Motivation for Contributing</h4><p>I decided to contribute to this site’s front end because I’ve been meaning to get more familiar with both React and Typescript. I also noticed that the site design was overseen by a professional designer and I was excited to get more experience working with/from with <a href="https://thedilldesign.com/web-design-comps-made/">comps</a> vs. something like bootstrap.</p><h4>What I made</h4><p>By following the specs and requirements shown in the <a href="https://github.com/mozilla/voice-web/issues/1408">initial issue</a>, I eventually ended up with the following:</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fgfycat.com%2Fifr%2Fdopeysinglehuemul&amp;url=https%3A%2F%2Fgfycat.com%2Fdopeysinglehuemul&amp;image=https%3A%2F%2Fthumbs.gfycat.com%2FDopeySingleHuemul-size_restricted.gif&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=gfycat" width="1920" height="1080" frameborder="0" scrolling="no"><a href="https://medium.com/media/fed0d38ebef884b7c6c38ac8b36d6b5d/href">https://medium.com/media/fed0d38ebef884b7c6c38ac8b36d6b5d/href</a></iframe><p>This component was fairly simple, but to implement it I needed to adopt the methods used by the project as a whole. Because of this there were a quite a few learning curves for me to get over. The purpose of this post will be to go over some of what I learned in overcoming them, linking to resources that readers might find useful along the way. If you plan on working on Typescript + React some of what’s covered here might help you solve certain issues in the future.</p><h3>Function vs. Class Components</h3><p>I never worked with Typescript + React before this project, so when I saw the following I got confused and encountered my first hurdle:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/650/1*yhdIQu5sVi88xM1IGizVLg.png" /><figcaption>Example of a functional component in the project</figcaption></figure><p>Combining React with Typescript means that fields will become statically typed. So when you’re passing state or properties into a functional component the data type of parameters will be stated before you reach the function implementation. A functional component without typescript might be easier to implement at first, but by not having type checking you can increase the number of bugs in your application as a whole. Type checking also has the advantage of making the code more readable, as you’ll immediately understand the type of parameters/return values in a function, it removes some guesswork.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/335/1*m-MXKHpwyRbnlSNsswrj1A.png" /><figcaption>Example of a simple function component without any Typescript.</figcaption></figure><p>Class components are a bit more complicated. With Typescript your React components state and property fields will be defined in interfaces, which can in turn extend other interfaces. <a href="https://blog.logrocket.com/@ogundipesamuel?source=post_header_lockup">Ogundipe Samuel</a> from LogRocket explained them well in <a href="https://blog.logrocket.com/how-why-a-guide-to-using-typescript-with-react-fffb76c61614">this post</a>, stating:</p><blockquote>One of TypeScript’s core principles is that type-checking focuses on the <em>shape </em>that values have. This is sometimes called “duck typing” or “structural subtyping”.</blockquote><blockquote>In TypeScript, interfaces fill the role of naming these types and are a powerful way of defining contracts within your code and contracts with code outside of your project.</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/620/1*5MCPtQ457IMg9gdNvAvXXw.png" /></figure><p>It wasn’t until I read <a href="https://levelup.gitconnected.com/ultimate-react-component-patterns-with-typescript-2-8-82990c516935">this</a> that I began to make sense of the function and class components above. For another more in-depth understanding you should check out <a href="https://medium.com/@Zwenza/functional-vs-class-components-in-react-231e3fbd7108">this post</a> as well.</p><p>In React it’s best to keep as many components as possible stateless. However I knew that for my Email Subscription component I’d want to keep track of its state; at a minimum I’d need to keep track of whether the component’s email input was valid or not so I could display certain styles or errors. So, needless to say I ended up creating a class component.</p><p>But a lot more needed to be added at this point. Since my component was essentially a form it needed to become a <a href="https://reactjs.org/docs/forms.html">controlled component</a>.</p><h3>Controlled Components</h3><p>In React, controlled components are recommended for implementing forms. Controlled components handle form data through the component’s state, while <a href="https://reactjs.org/docs/uncontrolled-components.html">uncontrolled components</a> handle form data in the DOM itself.</p><p>For example, for my html email input, I had a property called onChange that would trigger a handleChange()function. This function would then set the components state using this.setState().</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/660/1*zWARSEdByc7cAitLvHUpfg.png" /><figcaption>Input with an onChange function call to handleChange()</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/442/1*mFL_KwgOTmb7ZIiSCp4jDQ.png" /><figcaption>handleChange function that assigns the inputted value to the state directly</figcaption></figure><p>Adhering to this practice ensures that the component’s state is the ‘single source of truth’. Also, with an Uncontrolled component you may run into a issue withrefs. As <a href="https://www.codementor.io/blizzerand">Manjunath</a> in <a href="https://www.codementor.io/blizzerand/building-forms-using-react-everything-you-need-to-know-iz3eyoq4y">this article</a> states:</p><blockquote>React recommends using controlled components over refs to implement forms. Refs offer a backdoor to the DOM, which might tempt you to use it to do things the jQuery way. Controlled components, on the other hand, are more straightforward — the form data is handled by a React component. However, if you want to integrate React with a non-React project, or create a quick and easy form for some reason, you can use a ref.</blockquote><h3>Error Assigning to State</h3><p>When I first built my component and was attempting to assign to state, I would get an annoying error that didn’t make any real sense to me at the time:</p><blockquote>Cannot assign to ‘state’ because it is a constant or a read-only property</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*2rDUktcNj0m3vFnd.png" /><figcaption>A good example showing the cause of the error.</figcaption></figure><p>Looking at my code, nothing about it screamed ‘read-only’ to me, so I ended up relying on google to help me solve this one. Initially my search didn’t help me much, and at first lead me to believe that I ran into a possible regression error.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/750/1*2y9EQ5iQo8IjP1aAE-DXNw.png" /></figure><p>However as it turns out, <a href="https://github.com/DefinitelyTyped/DefinitelyTyped/pull/26813#issuecomment-400795486">the change was intentional</a>. <a href="https://github.com/DefinitelyTyped/DefinitelyTyped">DefinitelyTyped</a> — a file for integrating Typescript type checking into programs — created a new patch that changed the code’s behavior.</p><p>In an effort to improve type safety and prevent error prone code through accessing an undefined state, DefinatelyTyped made it so that a compile time error was created if a state variable was accessed but never initialized.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/651/1*2L0kyHFRnhl7ygPLvfBPRw.png" /><figcaption>This code demonstrates the problem. Notice how this.state.who is never initialized but still accessed; before the patch this would create a runtime error.</figcaption></figure><p>In addition to that assigning a value to this.state would throw an error if done in a constructor. This is because it’s bad practice to access the state in a constructor, since it could cause potential problems with mutability. So now whenever the state is accessed in such a way, the error:</p><blockquote>Cannot assign to ‘state’ because it is a constant or a read-only property</blockquote><p>Is shown during compile time.</p><p><a href="https://itnext.io/how-to-properly-define-state-in-react-components-47544eb4c15d">There are different approaches for fixing this</a>. For me, I was able to solve it by creating an interface for my state…</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/199/1*yOYa1rvCE0Vd9dhlty83dQ.png" /></figure><p>Using that as my state type in the component, then defining state fields in a single object set on state, within the constructor.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/550/1*U4OB7BAEUelKBFBCZAlNPQ.png" /></figure><h3>Final Review</h3><p>I got a fairly thorough review from one of the main contributors from voice-web after I made a <a href="https://github.com/mozilla/voice-web/pull/1675">PR for my changes</a>. I decided to add a section here based off a couple things that were mentioned.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/832/1*u92dGyVTJoLSAVJTD4LTaA.png" /></figure><p>This touches on an issue in another project I was working on, <a href="https://github.com/deepanjali19/GitHub-Dashboard">Github-Dashboard</a>. Developers were having css conflicts between pages because every css file imported into the project was having its selectors applied globally. There are many solutions to this problem, as outlined <a href="https://medium.com/@jviereck/modularise-css-the-react-way-1e817b317b04">here</a>. However here it was recommend that I namespace the selectors in sign-up.css .</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/834/1*qyXw-oTkeM_-S2dpGT5fRg.png" /></figure><p>Notice what was mentioned about constructors at the end, and how he mentions that they could be avoided. There’s a chance this is being recommended because the constructor adds redundancy by setting props, and can <a href="https://itnext.io/how-to-properly-define-state-in-react-components-47544eb4c15d">lead to mutations in state </a>if not handled properly.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/842/1*kStQsLtutr4mFv61c0whOQ.png" /></figure><p>If you see on line 35 here I set a component in my email subscription component’s state. But why is this a bad thing to do?</p><p>As mentioned in the <a href="http://web.archive.org/web/20150419023006/http://facebook.github.io/react/docs/interactivity-and-dynamic-uis.html">React docs</a>:</p><blockquote><strong>State should contain data that a component’s event handlers may change to trigger a UI update</strong>…adding redundant or computed values to state means that you need to explicitly keep them in sync rather than rely on React computing them for you.</blockquote><p><a href="http://brewhouse.io/blog/2015/03/24/best-practices-for-component-state-in-reactjs.html">State should have the simplest possible representation</a>, meaning that boolean flags should be used whenever possible instead of more complex values. Render() should compute data based off the state.</p><h3>Conclusion</h3><p>I think when I try to learn new technologies this will be the approach I take from now on, for the most part. Before my standard process would be to create small, personal, standalone projects that would practice what I’d have read in the documentation or some guide. But by contributing a feature to something already established by seasoned developers I have been able to adopt their good habits fairly early in my own development. It was a great experience and I learned a lot from this.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c9e0e5ab9c12" width="1" height="1" alt=""><hr><p><a href="https://medium.com/jkmdev-walkthroughs/working-with-react-and-typescript-to-create-a-newsletter-subscription-component-c9e0e5ab9c12">Working with React and Typescript to create a Newsletter Subscription component</a> was originally published in <a href="https://medium.com/jkmdev-walkthroughs">julias-guides</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>