<?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[Stories by Sean McPherson on Medium]]></title>
        <description><![CDATA[Stories by Sean McPherson on Medium]]></description>
        <link>https://medium.com/@seanmcp?source=rss-5ce6c0e94b9b------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*I0Uss-lgxydjuYO9mFgr5Q.jpeg</url>
            <title>Stories by Sean McPherson on Medium</title>
            <link>https://medium.com/@seanmcp?source=rss-5ce6c0e94b9b------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 24 Nov 2026 14:18:24 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@seanmcp/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Appalachian FC drops one of the best badges in US soccer]]></title>
            <link>https://medium.com/badgesfc/appalachian-fc-drops-one-of-the-best-badges-in-us-soccer-ff39f05971b?source=rss-5ce6c0e94b9b------2</link>
            <guid isPermaLink="false">https://medium.com/p/ff39f05971b</guid>
            <category><![CDATA[badges]]></category>
            <category><![CDATA[soccer]]></category>
            <category><![CDATA[review]]></category>
            <category><![CDATA[design]]></category>
            <category><![CDATA[npsl]]></category>
            <dc:creator><![CDATA[Sean McPherson]]></dc:creator>
            <pubDate>Thu, 26 Nov 2020 01:25:38 GMT</pubDate>
            <atom:updated>2020-11-26T01:25:38.026Z</atom:updated>
            <content:encoded><![CDATA[<p>The NPSL, National Premier Soccer League, announced the addition of Appalachian FC for the 2021 season. The club will play in Boone, NC, the home of Appalachian State University.</p><p>Expansion in the lower divisions of US soccer is always a good thing, but their badge is next level:</p><figure><img alt="Appalachian FC’s new badge" src="https://cdn-images-1.medium.com/max/865/1*pfuNQq65smEA-OfZcS4ygA.png" /></figure><p>The most striking feature of the badge might be the mascot: Big Foot or Sasquatch, a <a href="https://en.wikipedia.org/wiki/Bigfoot">cryptid famous in the forested regions of North America</a>. Appalachian FC is based in the mountains of western North Carolina, making Big Foot a perfect choice.</p><p>But beyond that are some key features that make this badge top notch.</p><p>The typeface is bold with angular cuts, evoking carved sign posts on mountain trails. The black and gold colors are striking and draw a connection to Appalachian State in town.</p><p>The oval is a classic badge shape, and they fill the space well with the tall mascot and full team lettering above and below. The space between “Appalachian” and “Football Club” is filled with evergreen trees, another tribute to the forests in their region.</p><p>Overall, a top-notch badge for a league that has some questionable entries. Hats off to the team at Appalachian FC!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ff39f05971b" width="1" height="1" alt=""><hr><p><a href="https://medium.com/badgesfc/appalachian-fc-drops-one-of-the-best-badges-in-us-soccer-ff39f05971b">Appalachian FC drops one of the best badges in US soccer</a> was originally published in <a href="https://medium.com/badgesfc">Badges FC</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Convert class components to functions with React Hooks]]></title>
            <link>https://medium.com/@seanmcp/convert-class-components-to-functions-with-react-hooks-9153271e721b?source=rss-5ce6c0e94b9b------2</link>
            <guid isPermaLink="false">https://medium.com/p/9153271e721b</guid>
            <category><![CDATA[front-end-development]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[react]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[react-hook]]></category>
            <dc:creator><![CDATA[Sean McPherson]]></dc:creator>
            <pubDate>Thu, 07 Feb 2019 17:50:33 GMT</pubDate>
            <atom:updated>2019-02-15T19:18:45.623Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Vdu-i1BwO56WzCfLjAu_Pg.jpeg" /><figcaption>A pile of carabiners that I’m going to pretend are hooks (Photo by <a href="https://proofpointisolation.com/browser?url=https%3A%2F%2Funsplash.com%2Fphotos%2FLu2pfy_8VKg%3Futm_source%3Dunsplash%26utm_medium%3Dreferral%26utm_content%3DcreditCopyText">Cameron Kirby</a> on <a href="https://proofpointisolation.com/browser?url=https%3A%2F%2Funsplash.com%2Fsearch%2Fphotos%2Fhooks%3Futm_source%3Dunsplash%26utm_medium%3Dreferral%26utm_content%3DcreditCopyText">Unsplash</a>)</figcaption></figure><p>Last year, the React team announced hooks, a feature to more easily abstract logic into reusable components. On the day of the announcement, <a href="https://medium.com/@seanmcp/refactoring-a-render-prop-with-hooks-fc22ed537199">I wrote and article</a> explaining how to refactor a render prop component with hook.</p><p>Starting this week with release of <a href="https://reactjs.org/blog/2019/02/06/react-v16.8.0.html">React v16.8</a>, <strong>you can now add hooks in your projects</strong>!</p><p>Today, I want to look at a typical class component and demonstrate how you can covert it into a functional component with React hooks. Let’s jump in.</p><h3>Terminology</h3><p><strong><em>Note</em></strong><em>: Skip this section if you’re familiar with class and functional React components.</em></p><p>I’m going to use the terms “class” and “functional” components to refer to the modern options for creating components. A class component looks something like this:</p><pre>class ClassExample extends React.Component {<br>  state = {<br>    greeting: &#39;Hello&#39;<br>  }<br>  render() {<br>    return (<br>      &lt;span&gt;<br>        {this.state.greeting}, {this.props.name}!<br>      &lt;/span&gt;<br>    )<br>  }<br>}</pre><p>Class components have access to internal state; default, custom, and lifecycle methods; and a this to reference. These components have been the powerhouses of React development throughout its history.</p><p>The aptly named functional components are functions that return JSX. Here’s a typical example:</p><pre>const FunctionalExample = props =&gt; {<br>  const greeting = &#39;Howdy&#39;<br>  return (<br>    &lt;span&gt;<br>      {greeting}, {props.name}!<br>    &lt;/span&gt;<br>  )<br>}</pre><p>Functional components lack an internal state, methods, and this. In order to access passed props, we refer to the props parameter.</p><p>Because they contain less internal logic, functional components are sometimes referred to as “dumb” or “presentational” components.</p><p>Although different in composition, class and functional components are used in the same manner. Let’s reference both examples from above in a hypothetical parent component:</p><pre>return (<br>  &lt;section&gt;<br>    &lt;ClassExample name=&quot;Sean&quot; /&gt;<br>    &lt;FunctionalExample name=&quot;partner&quot; /&gt;<br>  &lt;/section&gt;<br>)</pre><p>From the parent’s perspective, the two types of components are identical. To understand how React internally understands and processes these two different types of components, I recommend Dan Abramov’s <a href="https://overreacted.io/how-does-react-tell-a-class-from-a-function/">“How Does React Tell a Class from a Function?”</a>.</p><p>These are simplified definitions and examples, but they will provide us with a good basis for the rest of the article.</p><h3>Class component</h3><p>I have a component that makes an API request on mount, stores the response in state, then renders some JSX based on the data. Here’s the code:</p><pre>class ClassComponent extends React.Component {<br>  state = {<br>    url: null<br>  }<br>  componentDidMount() {<br>    fetch(&#39;https://random.dog/woof.json&#39;)<br>      .then(raw =&gt; raw.json())<br>      .then(res =&gt; this.setState(res))<br>  }<br>  render() {<br>    return (<br>      &lt;section&gt;<br>        &lt;h2&gt;Doggo!&lt;/h2&gt;<br>        {this.state.url ? (<br>          &lt;img src={this.state.url} alt=&quot;A cute dog&quot; /&gt;<br>        ) : (<br>          &lt;p&gt;Fetching&lt;/p&gt;<br>        )}<br>      &lt;/section&gt;<br>    )<br>  }<br>}</pre><p><strong><em>Note</em></strong><em>: To create this example, I looked through Todd Motto’s awesome list of </em><a href="https://github.com/toddmotto/public-apis"><em>“Public APIs”</em></a><em>. Check it out and give it a star if you find it useful.</em></p><p>I used the fetch library to keep the example straight forward (and it seemed fitting for an app that displays dog photos), but I recommend using a more robust option like <a href="https://github.com/axios/axios">Axios</a> with better error handling for your applications.</p><h3>Functional Component</h3><p>Using React Hooks, we can create the same example from above using a functional component.</p><h3>Setup</h3><p>First, we’ll create a new file for our functional code and set up a basic function. Then copy the return from our class component and remove all references to this.state. We need to declare a variable to prevent reference errors, so let’s call it url.</p><pre>const FunctionalComponent = props =&gt; {<br>  const url // We&#39;ll change this later<br>  return (<br>    &lt;section&gt;<br>      &lt;h2&gt;Doggo!&lt;/h2&gt;<br>      {url ? (<br>        &lt;img src={url} alt=&quot;A cute dog&quot; /&gt;<br>      ) : (<br>        &lt;p&gt;Fetching&lt;/p&gt;<br>      )}<br>    &lt;/section&gt;<br>  )<br>}</pre><h3>useEffect</h3><p>In our class component, we make an AJAX request when the component mounted and stored that data in state. componentDidMount and the other lifecycle methods are limited to classes. However, the React team was able to implement those features with the useEffect hook.</p><p>useEffect is a method that takes two parameters: 1) a function to call on mount, and 2) variables to watch for updating. For our example, we’ll only need the first of these two parameters.</p><p>For the first parameter, we’ll pass an anonymous function that calls fetch, processes the data, and logs the response. The second argument just be an empty array for now.</p><pre>const FunctionalComponent = props =&gt; {<br>  const url // We&#39;ll change this later<br>  React.useEffect(() =&gt; {<br>    fetch(&#39;https://random.dog/woof.json&#39;)<br>      .then(raw =&gt; raw.json())<br>      .then(res =&gt; console.log(res))<br>  }, [])<br>  return (<br>    &lt;section&gt;<br>      &lt;h2&gt;Doggo!&lt;/h2&gt;<br>      {url ? (<br>        &lt;img src={url} alt=&quot;A cute dog&quot; /&gt;<br>      ) : (<br>        &lt;p&gt;Fetching&lt;/p&gt;<br>      )}<br>    &lt;/section&gt;<br>  )<br>}</pre><p>If you are coding along, you should see something like the following in your console when the component mounts:</p><pre>{ &quot;url&quot;: &quot;https://random.dog/867580b3d005.jpg&quot; }</pre><p>This shows us that our API call is working, but logging the response isn’t our goal; we need to store the data for later. Let’s revisit the url variable that we created.</p><h3>useState</h3><p>Now that we have the response from our API, we need to be able to capture and reference that value. In our class component, we used its state and the setState method to remember that data.</p><p>React’s useState hook gives us access to a similar API without using a class. When calling the function and optionally passing a default value, we receive two returned variables: 1) a reference to the value, and 2) a function to update that value, respectively.</p><p>Using array destructuring, we can grab those variables and assign a name according to the convention: x and setX. For our example, we’ll call the value url and the setter function setUrl.</p><p>We’ll replace our old url with the results from useState:</p><pre>const FunctionalComponent = props =&gt; {<br>  const [url, setUrl] = React.useState(null)<br>  React.useEffect(() =&gt; {<br>    fetch(&#39;https://random.dog/woof.json&#39;)<br>      .then(raw =&gt; raw.json())<br>      .then(res =&gt; console.log(res))<br>  }, [])<br>  return (<br>    &lt;section&gt;<br>      &lt;h2&gt;Doggo!&lt;/h2&gt;<br>      {url ? (<br>        &lt;img src={url} alt=&quot;A cute dog&quot; /&gt;<br>      ) : (<br>        &lt;p&gt;Fetching&lt;/p&gt;<br>      )}<br>    &lt;/section&gt;<br>  )<br>}</pre><p>Using useState, we can quickly add basic state to our functional component.</p><p>In the code above, we’re just logging the response from our API. Now we want to use the setUrl function to set the value or url in our component’s state.</p><pre>const FunctionalComponent = props =&gt; {<br>  const [url, setUrl] = React.useState(null)<br>  React.useEffect(() =&gt; {<br>    fetch(&#39;https://random.dog/woof.json&#39;)<br>      .then(raw =&gt; raw.json())<br>      .then(res =&gt; setUrl(res.url))<br>  }, [])<br>  return (<br>    &lt;section&gt;<br>      &lt;h2&gt;Doggo!&lt;/h2&gt;<br>      {url ? (<br>        &lt;img src={url} alt=&quot;A cute dog&quot; /&gt;<br>      ) : (<br>        &lt;p&gt;Fetching&lt;/p&gt;<br>      )}<br>    &lt;/section&gt;<br>  )<br>}</pre><p>Now let’s take a second to revisit the second parameter passed to useEffect. Remember, it contains a list of variables that will trigger the effect to run again on change.</p><p>Our effect depends on one outside variable: setUrl. This function is generated once by useState, and adding it to the array will ensure that our fetch call isn’t fired repeatedly. (Hat tip to <a href="https://medium.com/u/683803defb1e">Hung Tran Van</a> for this fix)</p><pre>const FunctionalComponent = props =&gt; {<br>  const [url, setUrl] = React.useState(null)<br>  React.useEffect(() =&gt; {<br>    fetch(&#39;<a href="https://random.dog/woof.json&#39;">https://random.dog/woof.json&#39;</a>)<br>      .then(raw =&gt; raw.json())<br>      .then(res =&gt; setUrl(res.url))<br>  }, [setUrl])<br>  return (<br>    &lt;section&gt;<br>      &lt;h2&gt;Doggo!&lt;/h2&gt;<br>      {url ? &lt;img src={url} alt=&quot;A cute dog&quot; /&gt; : &lt;p&gt;Fetching&lt;/p&gt;}<br>    &lt;/section&gt;<br>  )<br>}</pre><p>That’s it! Checkout a <a href="https://codesandbox.io/s/wwvmq1v407">live example</a> powered by CodeSandbox to see the two components side-by-side:</p><p><a href="https://codesandbox.io/s/wwvmq1v407">https://codesandbox.io/s/wwvmq1v407</a></p><h3>Comparison</h3><p>Let’s take a moment and consider our two components. The new functional component is a little shorter than the original class component, and the variables are shorter and easier to reference.</p><p>That are nice benefits, but I don’t find either a convincing reason to go back and convert all my class components.</p><p>More important to me is the fact that <strong>you can now use a functional component for nearly everything in your application</strong>. Since every component is functional, it makes the process of bringing in or removing state and lifecycle effects much easier.</p><h3>Embrace the class-less future</h3><p>For those reasons and others, the future of React is class-less. And that’s a good thing. Hooks provide more flexibility when creating and managing components, to say nothing of <a href="https://reactjs.org/docs/hooks-custom.html">custom hooks</a>.</p><p>But don’t panic and convert all your class components right now; <a href="https://twitter.com/dan_abramov/status/1026839679197437953">“they’ll be supported for a looooong time”</a>. However, when you have the opportunity to refactor a class component going forward, consider converting it into a functional component with hooks.</p><p>I hope that helps! Let me know if you have any questions, comments, or corrections on Twitter: <a href="https://twitter.com/_seanmcp">@_seanmcp</a>.</p><p>Happy coding!</p><p><em>Originally published at </em><a href="https://www.seanmcp.com/articles/convert-class-component-to-function-with-hooks/"><em>www.seanmcp.com</em></a><em>.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9153271e721b" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[ ⚛️ — Introducing a11y-react-emoji]]></title>
            <link>https://medium.com/@seanmcp/%EF%B8%8F-introducing-a11y-react-emoji-8b0c31a96814?source=rss-5ce6c0e94b9b------2</link>
            <guid isPermaLink="false">https://medium.com/p/8b0c31a96814</guid>
            <category><![CDATA[npm]]></category>
            <category><![CDATA[react]]></category>
            <category><![CDATA[emoji]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[components]]></category>
            <dc:creator><![CDATA[Sean McPherson]]></dc:creator>
            <pubDate>Fri, 18 Jan 2019 20:07:07 GMT</pubDate>
            <atom:updated>2019-01-19T00:56:41.914Z</atom:updated>
            <content:encoded><![CDATA[<h3>👍 ⚛️ — Introducing a11y-react-emoji</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*B_mYvm0zUc0O9hxl" /><figcaption>Photo by <a href="https://unsplash.com/@rawpixel?utm_source=medium&amp;utm_medium=referral">rawpixel</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>Last April, I wrote an article titled “<a href="https://medium.com/@seanmcp/%EF%B8%8F-how-to-use-emojis-in-react-d23bbf608bf7">👋 ⚛️ — How to use emojis in React</a>.” I felt silly for writing it and didn’t think twice when the article sat unnoticed for a few weeks. Then, thanks to Google’s indexing, the article starting appearing on searches for “React” and “emoji”, resulting in a steady stream of traffic.</p><p>Nine months later, it has over 200 claps and is (by far) my most popular article on Medium.</p><p>I’m glad that so many people have found the article useful, but I have always felt badly about how it ended. I shared a component for using accessible emojis in React but left the reader with no way to implement it without copying and pasting. That’s not a great conclusion in my book.</p><p>Well, I am happy to report that the problem finally has a sharable solution. I turned the component from my original article into <a href="https://www.npmjs.com/package/a11y-react-emoji">a React component library called </a><a href="https://www.npmjs.com/package/a11y-react-emoji">a11y-react-emoji</a>!</p><h3>Hello accessible React emojis!</h3><p>a11y-react-emoji has one goal: provide an easy and accessible solution for using emojis in React applications. It achieves this by offering a reusable Emoji component with a simple API that outputs accessible markup.</p><p>It works like this:</p><pre>// This JSX</pre><pre>&lt;Emoji symbol=&quot;🚀&quot; label=&quot;a rocket blasting off&quot; /&gt;</pre><pre>// yields this HTML</pre><pre>&lt;span aria-label=&quot;a rocket blasting off&quot; role=&quot;img&quot;&gt;🚀&lt;/span&gt;</pre><p>This follows the pattern recommended by <a href="http://tink.uk/accessible-emoji/">Léonie Watson</a> and used by <a href="https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/accessible-emoji.md">eslint-plugin-jsx-a11y</a>.</p><p>In instances where you are using an emoji for purely decorative purposes, you can forego the label prop and just use the following:</p><pre>// For decorative emojis, leave out a label</pre><pre>&lt;Emoji symbol=&quot;🤫&quot; /&gt;</pre><pre>// and Emoji sets an aria attribute to hide it from screen readers</pre><pre>&lt;span aria-hidden=&quot;true&quot; role=&quot;img&quot;&gt;🤫&lt;/span&gt;</pre><p>That’s it! By keeping the API simple, I’m hoping that applications will be more willing to use this accessible emoji solution.</p><p>For more information, check out the <a href="https://medium.com/%5B%3Chttps://github.com/seanmcp/a11y-react-emoji#readme%3E%5D(%3Chttps://github.com/seanmcp/a11y-react-emoji#readme%3E)">official documentation</a>.</p><h3>Give it a try!</h3><p>To add a11y-react-emoji, simply use your favorite package manager:</p><pre>npm install --save a11y-react-emoji<br># or<br>yarn add a11y-react-emoji</pre><p>Import the Emoji component, and get going:</p><pre>import Emoji from &#39;a11y-react-emoji&#39;</pre><pre>function HeartFooter() {<br>    return (<br>        &lt;footer&gt;<br>            Made with<br>            {&#39; &#39;}<br>            &lt;Emoji symbol=&quot;❤️&quot; label=&quot;love&quot; /&gt;<br>            {&#39; &#39;}<br>            by Sean McPherson<br>        &lt;/footer&gt;<br>    )<br>}</pre><h3>Feedback</h3><p>If you run into any bugs, please <a href="https://medium.com/%5B%3Chttps://github.com/SeanMcP/a11y-react-emoji/issues/new%3E%5D(%3Chttps://github.com/SeanMcP/a11y-react-emoji/issues/new%3E)">file an issue on GitHub</a>. Leave any other questions or comments here.</p><p>Happy coding!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8b0c31a96814" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Understanding and organizing dependencies in node packages]]></title>
            <link>https://medium.com/@seanmcp/understanding-and-organizing-dependencies-in-node-packages-13d34560e001?source=rss-5ce6c0e94b9b------2</link>
            <guid isPermaLink="false">https://medium.com/p/13d34560e001</guid>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[dependencies]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[package-manager]]></category>
            <category><![CDATA[nodejs]]></category>
            <dc:creator><![CDATA[Sean McPherson]]></dc:creator>
            <pubDate>Fri, 11 Jan 2019 19:39:21 GMT</pubDate>
            <atom:updated>2019-01-11T19:39:21.045Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*1o5m78osm1bQ-yTcrCB2Tw.jpeg" /><figcaption>By Photographed by me. Item in Muckleburgh Collection., Public Domain, <a href="https://commons.wikimedia.org/w/index.php?curid=2222483">https://commons.wikimedia.org/w/index.php?curid=2222483</a></figcaption></figure><p>One of the best parts of JavaScript development in 2019 is the number of awesome libraries to add to your project. By utilizing community packages, we can tap our collective knowledge and create applications that are beyond the scope of any one developer’s ability.</p><p>Managing these dependencies, however, can be a difficult task, especially for new developers. Fortunately, npm’s package.json has a built-in way for organizing dependencies.</p><p>But first, let’s take a step back and answer: what is a dependency?</p><h3>Overview</h3><p>Dependencies are packages or libraries that your application depends on to function. If you’re creating a React application, for example, you need to have Facebook’s react listed as a dependency for your app to work.</p><p>In order to add a dependency to you project, you just need to run an install command:</p><pre>npm install --save name-of-package<br># or<br>yarn add name-of-package</pre><p>The commands above will download the package from npm, add the contents to a created node_modules/ directory, then add the downloaded package to your app&#39;s package.json in one of five dependency types:</p><ol><li>dependencies (default)</li><li>devDependencies</li><li>peerDependencies</li><li>bundledDependencies</li><li>optionalDependencies</li></ol><p>Within those dependency objects*, packages are listed by their name and the version:</p><pre>{<br>  &quot;dependencies&quot;: {<br>    &quot;react&quot;: &quot;16.5.2&quot;,<br>    &quot;react-dom&quot;: &quot;16.5.2&quot;,<br>    &quot;react-scripts&quot;: &quot;2.0.3&quot;<br>  }<br>}</pre><p><em>Note: bundledDependencies are listed in an array, not an object.</em></p><p>Let’s look at each of those dependency types separately.</p><h3>Dependencies</h3><p>By default, installing a new package will add it to the dependencies field of your package.json. As I mentioned above, these are the packages that your application needs to run.</p><p>As a general rule: anything that you import or require in your project needs to be included as a default dependency.</p><pre>import React from &#39;react&#39;<br>// or<br>var classNames = require(&#39;classnames&#39;)</pre><p>For smaller personal projects or experiments, adding every dependency to dependencies is fine. But as the size of your application grows, you will want to move some of your dependencies into other categories.</p><p>If you are creating a package, then you will want to be careful about what default dependencies you add. Whenever someone installs your package, they will also install every package listed as a dependency in your package.json. The chain continues, adding every dependency in every dependency in node_modules.</p><p>As a result, an application’s node_modules directory can become enormous, especially if non-essential dependencies are included as default dependencies. To avoid this, consider moving your dependencies to devDependencies or peerDependencies instead.</p><h3>DevDependencies</h3><p>DevDependencies, or development dependencies, are packages that you only need when developing your application. DevDependencies are useful, but are not mission critical: the application will still run without them.</p><p>You add a devDependency by including an option to your favorite install command:</p><pre>npm install --save-dev name-of-package<br># or<br>yarn add --dev name-of-package</pre><p>An example of a common devDependency is <a href="https://prettier.io/">Prettier</a>, a popular code formatter. When working on your app, you may want to use a formatter like Prettier in order to normalize the code throughout the project as a <a href="https://medium.com/%5B%3Chttps://git-scm.com/book/en/v2/Customizing-Git-Git-Hooks%3E%5D(%3Chttps://git-scm.com/book/en/v2/Customizing-Git-Git-Hooks%3E)">pre-commit hook</a> or <a href="https://medium.com/%5B%3Chttps://docs.npmjs.com/misc/scripts%3E%5D(%3Chttps://docs.npmjs.com/misc/scripts%3E)">script</a>.</p><p>This is a good and useful practice in development, but Prettier will never be run in production. Which means that prettier, as a dependency, will never be used once your code is deployed.</p><p>By listing prettier as a devDependency instead of a default dependency, you prevent it from being unnecessarily installed in a production environment.</p><h3>PeerDependencies</h3><p>The third type of dependencies I will mention are peerDependencies. These are only important when you are creating a package or plugin that will be used by others.</p><p>This <a href="https://medium.com/%5B%3Chttps://stackoverflow.com/a/34645112/8486161%3E%5D(%3Chttps://stackoverflow.com/a/34645112/8486161%3E)">StackOverflow answer</a> explains it well:</p><blockquote>peerDependencies is for dependencies that are exposed to (and expected to be used by) the consuming code, as opposed to “private” dependencies that are not exposed, and are only an implementation detail.</blockquote><p>Let’s say you’re working on a React component library. You know that it will only be used in a project that already has react listed as a dependency. Since React is already included in the project, the package manager won&#39;t need to install it again.</p><p>PeerDependencies don’t have any code that is included in your project, so they just need to be manually listed in a peerDependencies object in your package.json.</p><pre>{<br>  &quot;peerDependencies&quot;: {<br>    &quot;name-of-package&quot;: &quot;1.0.2&quot;<br>  }<br>}</pre><p>If you’re using the yarn package manager, you can use the following to add a peer dependency automatically:</p><pre>yarn add --peer name-of-package</pre><h3>BundledDependencies &amp; OptionalDependencies</h3><p><a href="https://medium.com/%5B%3Chttps://docs.npmjs.com/files/package.json#bundleddependencies%3E%5D(%3Chttps://docs.npmjs.com/files/package.json#bundleddependencies%3E)">BundledDependencies</a> and <a href="https://medium.com/%5B%3Chttps://docs.npmjs.com/files/package.json#optionaldependencies%3E%5D(%3Chttps://docs.npmjs.com/files/package.json#bundleddependencies%3E)">OptionalDependencies</a> are far less common and are beyond the scope of this article. Refer to the documentation on npm for a detailed description.</p><h3>Summary</h3><p>When adding packages to your project, there are three main routes to take: dependencies, devDependencies, and peerDependencies.</p><p>Here’s how I remember where to include my dependencies:</p><ol><li>dependencies: my app needs this package to run</li><li>devDependencies: I need this package when working on my app</li><li>peerDependencies: my package expects the project to have this library already</li></ol><p>I hope that helped! Let me know if you have any helpful tips for organizing dependencies in your projects.</p><p>Happy coding!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=13d34560e001" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[2018 into 2019]]></title>
            <link>https://medium.com/@seanmcp/2018-into-2019-cf9fd5a4fdfe?source=rss-5ce6c0e94b9b------2</link>
            <guid isPermaLink="false">https://medium.com/p/cf9fd5a4fdfe</guid>
            <category><![CDATA[year-in-review]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[npm]]></category>
            <category><![CDATA[react]]></category>
            <category><![CDATA[javascript]]></category>
            <dc:creator><![CDATA[Sean McPherson]]></dc:creator>
            <pubDate>Mon, 31 Dec 2018 20:37:29 GMT</pubDate>
            <atom:updated>2018-12-31T20:37:29.380Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*GubYXmlN-67GmS-x" /><figcaption>Photo by <a href="https://unsplash.com/@chisathon?utm_source=medium&amp;utm_medium=referral">Chris Gilbert</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>As 2018 comes to a close, I was inspired by <a href="https://www.taniarascia.com/2018-into-2019/">Tania Rascia</a> to write a year in review. I’m hoping to turn this into an annual opportunity to reflect on the successes, failures, and challenges from the previous year, and set goals for the next.</p><p>2018 was probably the most eventful year of my life, edging 2014 in which I graduated from college, married, and received my first teaching position. I’ve attempted to list all of the major events and accomplishments of the past year in mostly chronological order.</p><h3>2018 in review</h3><p>Last year, I:</p><ul><li><strong>Received three tech job offers</strong>: Node developer with a crypto company, QA with CNN Politics, and React Developer with TSYS</li><li><strong>Accepted my first software developer position</strong>: TSYS offered a contract-to-hire position that worked well for my family</li><li><strong>Deployed two apps</strong>: <a href="https://seanmcp.github.io/dice-roller/">Dice Roller</a> and <a href="https://seanmcp.github.io/contraction-tracker/">Contraction Tracker</a></li><li><strong>Attended two conferences</strong>: NG ATL, and Connect Tech</li><li><strong>Became a father</strong>: My first child was born in March, changing our lives forever</li><li><strong>Converted from contract to salaried employee</strong>: After a three-month trial, TSYS was happy to offer me an official position with the company</li><li><strong>Organized</strong> <a href="https://www.meetup.com/jrdevsatl/"><strong>Jr Devs</strong></a>: a Meetup for learners with over 200 members</li><li><strong>Gave a lightning talk at a Meetup</strong>: <a href="https://github.com/jr-devs/meetup/blob/master/events/june-2018.md">Intro to CSS Animations</a></li><li><strong>Learned some Python</strong>: created a few scripts, a Flask app for gaming, and a text-based adventure game <a href="https://github.com/SeanMcP/rimoria">Rimoria</a></li><li><strong>Created two NPM packages</strong>: <a href="https://www.npmjs.com/package/vanilla-include">vanilla-include</a> and <a href="https://www.npmjs.com/package/nodify-string">nodify-string</a></li><li><strong>Represented TSYS</strong> at a job fair</li><li>Worked on an application at work in <strong>React Native</strong></li><li><strong>Launched a Chrome extension</strong>: <a href="https://chrome.google.com/webstore/detail/popsicle-sticks-random-st/lnckbgaeagindapiodcmccfokcmnfecm">Popsicle Sticks</a></li><li>Helped TSYS create an <a href="https://medium.com/tsys-engineering"><strong>engineering blog</strong></a> and <a href="https://github.com/tsys"><strong>GitHub organization</strong></a></li><li>Published <strong>12 articles</strong> (including two on this website)</li></ul><p>After sitting down and writing it all out, I am impressed with the things that I have accomplished in 2018. Especially considering how uncertain I was about continuing my search for work in the tech industry by the end of 2017.</p><p>Last year was a long stretch of giving from God: blessed be the name of the LORD (<a href="https://www.biblegateway.com/passage/?search=Job+1&amp;version=NKJV">read Job 1</a>).</p><h3>Previewing 2019</h3><p>Looking forward to next year, there are several things that I want to learn and do. I am going to list some general goals, followed by measurable ways that I can accomplish them.</p><ul><li><strong>Python</strong>: I want to dive deeper in Python applications, including environments and dependencies, by <strong>deploying a Python app</strong></li><li><strong>Machine learning</strong>: TSYS is interested in integrating ML into their applications, so I will <strong>complete a course</strong> in either Udacity or Udemy</li><li><strong>Module bundlers</strong>: I am lost (and confused) when it comes to module bundling, so I am going to de-mystify bundlers by publishing React <strong>setup guides for Webpack, Parcel, and Rollup</strong></li><li><strong>NPM Packages</strong>: I want to learn about creating and maintaining open-source software by publishing <strong>two new packages</strong></li><li><strong>Tooling</strong>: I want to investigate tooling options for React development that streamline the process and <strong>create a personalized dot files repo</strong></li><li><strong>Publish more articles</strong>: It is my mission to help people, and one way to do that is to publish <strong>24 articles (bi-monthly)</strong></li><li><strong>Jr Devs Meetup</strong>: I want to partner with a coding bootcamp to provide <strong>instructors at every meeting</strong></li><li><strong>Speaking</strong>: I want to create a deck and <strong>present at another Meetup</strong></li><li><strong>Husband</strong>: I want to take dating my wife seriously and <strong>schedule a babysitter four times a year</strong> for real dates</li><li><strong>Father</strong>: I want to use the time I have with my son more productively, <strong>going on father-son outings twice a month</strong></li><li><strong>Faith</strong>: I want to <strong>continue teaching Sunday school</strong>, lead <strong>family worship every evening</strong>, and <strong>read/reflect on the Bible daily</strong></li><li><strong>Personal</strong>: Dad bod is a real thing and is only around the corner, so I want to <strong>exercise 6 days a week</strong> (don’t forget a <a href="https://www.biblegateway.com/passage/?search=Ex+20%3A8-11&amp;version=NKJV">day of rest</a>)</li><li><strong>Soccer</strong>: I want to find room in the family schedule to <strong>play a pick-up game every week</strong></li></ul><p>I could go on longer, but twelve seems like a fitting number. I am going to check back on these goals throughout the year and track my progress in a different article.</p><h3>How was your year?</h3><p>As I mentioned above, this is not a new or unique idea. But I think it’s a good one, and I encourage you to give it a try. You might be pleasantly surprise (like I was), at how much you’ve accomplished.</p><p>If not, then ask yourself: What can I do to help myself accomplish my goals next year? You don’t need to be a super hero; just try to be a little better than you were the day before.</p><p>I hope this was half as inspiring to you as it was helpful to me. Happy new year! 🎉</p><p><em>Originally published at </em><a href="https://www.seanmcp.com/articles/2018-into-2019/"><em>www.seanmcp.com</em></a><em>.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=cf9fd5a4fdfe" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How (and when) to use BEM in React]]></title>
            <link>https://medium.com/@seanmcp/how-and-when-to-use-bem-in-react-edabad2b805a?source=rss-5ce6c0e94b9b------2</link>
            <guid isPermaLink="false">https://medium.com/p/edabad2b805a</guid>
            <category><![CDATA[front-end-development]]></category>
            <category><![CDATA[react]]></category>
            <category><![CDATA[bem]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[css]]></category>
            <dc:creator><![CDATA[Sean McPherson]]></dc:creator>
            <pubDate>Thu, 20 Dec 2018 17:03:36 GMT</pubDate>
            <atom:updated>2018-12-20T17:03:36.976Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*LIHo8xyLo_SFJfaF0cWBow.jpeg" /><figcaption>By Belinda Hankins Miller from U.S.A. — block wagon, by Bella / This is Today 28, CC BY 2.0, <a href="https://commons.wikimedia.org/w/index.php?curid=3375029">https://commons.wikimedia.org/w/index.php?curid=3375029</a></figcaption></figure><p>When working on an enterprise application, every developer should make decisions with scalability in mind. On the frontend, a major pain point for applications as they grow is their styles.</p><p>Some of the style-related problems fall into the following categories:</p><ul><li><strong>Unintended inheritance</strong>: global styles and helper classes that were created with the best intentions are day one can come back to haunt you on day 200</li><li><strong>Conflicts with dependency APIs</strong>: UI toolkits and component libraries like Bootstrap can eliminate common class names from consideration (<em>e.g.</em> row, button)</li><li><strong>Class name strain</strong>: creating unique classes to avoid the above problems can take real time and mental energy</li><li><strong>Structural dependence</strong>: components styled with CSS child selectors may avoid name-related problems but break down with a light refactor</li></ul><p>Working on a large and growing application, I have run into all four of this issues (and more). However, with a codified CSS system, developers can avoid these problems going forward. One of those systems is <a href="http://getbem.com/">BEM</a>.</p><h3>BEM</h3><p>BEM, or Block-Element-Modifier, is a popular solution that establishes a system for quickly creating unique classes for every tag on the screen.</p><p>BEM’s strict naming system aims to help your development process by reducing how long it takes you to write code, how much of that code you’ll have to write, and how much loading your browser will have to do (<a href="http://getbem.com/introduction/">See BEM Introduction)</a>.</p><p>To look at BEM in action, we’ll look at the following toast messages:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5rfBvakc245CBS83YpxIDQ.png" /></figure><p>Your React component might be structured something like this:</p><pre>function Toast(props) {<br>  return (<br>    &lt;div&gt;<br>      &lt;main&gt;<br>        &lt;header&gt;{props.category}&lt;/header&gt;<br>        &lt;p&gt;{props.message}&lt;/p&gt;<br>      &lt;/main&gt;<br>      &lt;button<br>        type=&quot;button&quot;<br>        onClick={props.dismiss}<br>      &gt;<br>        Dismiss<br>      &lt;/button&gt;<br>    &lt;/div&gt;<br>  )<br>}</pre><p>BEM will determine what classes we add and where in order to style our component. Let’s start at the top.</p><h4>Blocks</h4><p>The first level of the BEM system is the block. This is the parent element that will be used as a namespace for the rest of your elements. In React parlance, think of a block as a component.</p><p>There are different naming conventions within BEM, but I believe it makes most sense in React to reuse the component’s name (in pascal case) as the block-level class name. We’ll add that to our component.</p><pre>function Toast(props) {<br>  return (<br>    &lt;div <strong>className=&quot;Toast&quot;</strong>&gt;<br>      &lt;main&gt;<br>        &lt;header&gt;{props.category}&lt;/header&gt;<br>        &lt;p&gt;{props.message}&lt;/p&gt;<br>      &lt;/main&gt;<br>      &lt;button<br>        type=&quot;button&quot;<br>        onClick={props.dismiss}<br>      &gt;<br>        Dismiss<br>      &lt;/button&gt;<br>    &lt;/div&gt;<br>  )<br>}</pre><h4>Elements</h4><p>After blocks, the next level in BEM is the element. Elements are children of blocks and are named with the following convention: Block__element with two underscores (_). Every element’s class name includes a reference to the parent Block, (almost) guaranteeing a unique reference.</p><p>We have a few elements in our component, so I will sprinkle in some appropriate class names:</p><pre>function Toast(props) {<br>  return (<br>    &lt;div className=&quot;Toast&quot;&gt;<br>      &lt;main <strong>className=&quot;Toast__message&quot;</strong>&gt;<br>        &lt;header <strong>className=&quot;Toast__message-category&quot;</strong>&gt;<br>          {props.category}<br>        &lt;/header&gt;<br>        &lt;p <strong>className=&quot;Toast__message-text&quot;</strong>&gt;{props.message}&lt;/p&gt;<br>      &lt;/main&gt;<br>      &lt;button<br>        <strong>className=&quot;Toast__button&quot;</strong><br>        type=&quot;button&quot;<br>        onClick={props.dismiss}<br>      &gt;<br>        Dismiss<br>      &lt;/button&gt;<br>    &lt;/div&gt;<br>  )<br>}</pre><p>Notice that in the case of Toast__message, I have two elements within an element. Some strict adherents to BEM prefer chaining elements like so: Toast__message__category. This is a matter of preference, and I have opted for the (slightly) simpler Toast__message-category.</p><p>Now that we have unique class names for our Block and elements, we can add the bulk of the styles required to match the mockup.</p><p>If you remember the original, there were three types of Toast message: success, warning, and error. In order to add those styles, we’ll use the third level of BEM: modifiers.</p><h4>Modifiers</h4><p>In BEM, modifiers can be appended to either blocks or elements to add conditional styles. The naming convention references the element to be modified: Block--modifier or Block__element--modifier with two hyphens (-).</p><p>For our toast messages, I’ll modify the block with the category:</p><pre>function Toast(props) {<br>  return (<br>    &lt;div <strong>className={`Toast Toast--${props.category}`}</strong>&gt;<br>      &lt;main className=&quot;Toast__message&quot;&gt;<br>        &lt;header className=&quot;Toast__message-category&quot;&gt;<br>          {props.category}<br>        &lt;/header&gt;<br>        &lt;p className=&quot;Toast__message-text&quot;&gt;{props.message}&lt;/p&gt;<br>      &lt;/main&gt;<br>      &lt;button<br>        className=&quot;Toast__button&quot;<br>        type=&quot;button&quot;<br>        onClick={props.dismiss}<br>      &gt;<br>        Dismiss<br>      &lt;/button&gt;<br>    &lt;/div&gt;<br>  )<br>}</pre><p>With all of our BEM classes in place, we can finish styling our three Toast messages.</p><h4>Example</h4><p>You can view the components and styles above on this CodePen:</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fcodepen.io%2FSeanMcP%2Fembed%2Fpreview%2FmarZrx%3Fheight%3D600%26slug-hash%3DmarZrx%26default-tabs%3Djs%2Cresult%26host%3Dhttps%3A%2F%2Fcodepen.io&amp;url=https%3A%2F%2Fcodepen.io%2FSeanMcP%2Fpen%2FmarZrx&amp;image=https%3A%2F%2Fs3-us-west-2.amazonaws.com%2Fi.cdpn.io%2F174428.marZrx.small.29887d5f-eb0f-4a5d-9de4-bafdff448a55.png&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=codepen" width="800" height="600" frameborder="0" scrolling="no"><a href="https://medium.com/media/9927b3f82c437716dde1e9a7336bbe88/href">https://medium.com/media/9927b3f82c437716dde1e9a7336bbe88/href</a></iframe><h3>Overview</h3><p>If the above example was too long or too specific, here are the core principles to know when using BEM in React:</p><ul><li><strong>Components are blocks</strong>: match the top-level tag’s class name with the name of your component (<em>e.g.</em> UserProfile.jsx, className=&quot;UserProfile&quot;)</li><li><strong>Element names refer to the component</strong>: every class name within a component should start with the name of the component and two underscores (<em>e.g.</em> className=&quot;UserProfile__icon&quot;)</li><li><strong>Modifiers are added to blocks, elements</strong>: add conditional styles by appending a modifier class that refers to the element being modified (<em>e.g.</em> className=&quot;UserProfile--disabled&quot;, className=&quot;UserProfile__icon--round)</li></ul><p>With all this in mind, I tried using BEM exclusively on a growing enterprise application. Here are my observations:</p><h4>Strengths</h4><p>By following BEM’s strict naming system, I was able to avoid all of the problems mentioned at the outset of the article: <strong>unintended inheritance</strong>, conflicts with <strong>dependency APIs</strong>, <strong>class name strain</strong>, and <strong>structural dependence</strong>.</p><p>Once I got into the rhythm of naming blocks, elements, and modifiers, the process of generating unique class names was <strong>smooth</strong> and <strong>relatively painless</strong>.</p><p>Perhaps the best benefit of the system is <strong>readability</strong>. I found that I could switch back to a component’s JSX or stylesheet and instantly understand what classes corresponded with which styles and <em>vice versa</em>. What BEM class names lack in brevity, they make up in <strong>clarity</strong>.</p><p>There were some noticeable drawbacks to using BEM in React as well.</p><h4>Weaknesses</h4><p>I just finished saying that the clarity of BEM’s class names was a strength, and that is true — to an extent. At a certain length, those clear classnames became a liability.</p><p>Creating long chains of element names can quickly become cumbersome and “clog” up the JSX of a component (<em>e.g. </em>ProfileEditorContainer__heading__profile-image is 46 characters!).</p><p>Additionally, highly conditional components can become nearly unmanageable. Consider the following scenario:</p><pre>&lt;div<br>  className={`UserProfile ${<br>    props.isSelected ? &#39;UserProfile--selected&#39; : &#39;&#39;<br>  } ${<br>    props.isFeatured ? &#39;UserProfile--featured&#39; : &#39;&#39;<br>  } ${<br>    props.rtl ? &#39;UserProfile--rtl&#39; : &#39;&#39;<br>  } ${<br>    props.className ? props.className : &#39;&#39;<br>  }`}<br>&gt;</pre><p>To be fair, the above example could be simplified with a library like <a href="https://github.com/JedWatson/classnames#readme">classnames</a>, but it remains that the verbosity of BEM is magnified by every condition added to a component.</p><p>When a child component needed to receive special styles and/or positioning from a parent, BEM failed to provide a solution to my liking. Should the parent pass a class like Parent__child, or Child--parent? It felt unnatural either way with the system breaking in either the parent’s stylesheet or child’s HTML.</p><h4>Last word</h4><p>BEM is a rock-solid system with wide support throughout the industry. It excels by establishing a system that solves some of the biggest scalability problems facing front-end applications. In highly interactive React applications, however, BEM seems to struggle to manage component conditions effectively.</p><p>If you’re looking for a class-based solution to your applications style system, I recommend that you give BEM a try. It may not be the best solution in every situation, but it is a tried and true option.</p><p>I hope that helps! Leave your comments, questions, and/or criticism below.</p><p>Happy coding!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=edabad2b805a" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[A11y resources for universal web development]]></title>
            <link>https://medium.com/@seanmcp/a11y-resources-for-universal-web-development-7c98965d7228?source=rss-5ce6c0e94b9b------2</link>
            <guid isPermaLink="false">https://medium.com/p/7c98965d7228</guid>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[accessibility]]></category>
            <category><![CDATA[accessible]]></category>
            <category><![CDATA[a11y]]></category>
            <dc:creator><![CDATA[Sean McPherson]]></dc:creator>
            <pubDate>Thu, 08 Nov 2018 19:49:36 GMT</pubDate>
            <atom:updated>2018-11-13T16:16:20.726Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*MyrTq2gkQPO-0fpl3JJbjQ.jpeg" /><figcaption>By Michael3 — Own work, Public Domain, <a href="https://commons.wikimedia.org/w/index.php?curid=12038367">https://commons.wikimedia.org/w/index.php?curid=12038367</a></figcaption></figure><blockquote>This is a growing collection of resources and tools for learning about and developing accessible web applications. If you have any resource suggestions, please leave a comment. <em>👍</em></blockquote><h3>Documentation</h3><ul><li><a href="https://www.w3.org/TR/wai-aria-1.1/">Accessible Rich Internet Applications (WAI-ARIA) 1.1</a> by W3C</li></ul><h4>Quick reference</h4><ul><li><a href="https://www.w3.org/TR/wai-aria-1.1/#role_definitions">Definition of Roles</a></li><li><a href="https://www.w3.org/TR/wai-aria-1.1/#state_prop_def">Definitions of States and Properties (all aria-* attributes)</a></li></ul><h3>Articles</h3><h4>Overviews</h4><ul><li><a href="https://developers.google.com/web/fundamentals/accessibility/">Accessibility | Web Fundamentals</a> by Google</li><li><a href="https://www.sitepoint.com/how-to-use-aria-effectively-with-html5/">How to Use ARIA Effectively with HTML5</a> by Georgie Luhur (SitePoint)</li><li><a href="https://webaim.org/blog/aria-cause-solution/">To ARIA! The Cause of, and Solution to, All Our Accessibility Problems</a> by Jon Whiting (WebAIM)</li><li><a href="https://www.w3.org/TR/wai-aria-practices/">WAI-ARIA Authoring Practices 1.1</a> by W3C</li><li><a href="https://developer.mozilla.org/en-US/docs/Learn/Accessibility/WAI-ARIA_basics">WAI-ARIA Basics</a> by MDN</li></ul><h4>Specific strategies</h4><ul><li><a href="https://webdesign.tutsplus.com/tutorials/use-the-lang-attribute-for-better-accessibility--cms-31961">Quick Tip: Use the “lang” Attribute for Better Accessibility</a> by Eric Bailey (EnvatoTuts+)</li></ul><h3>Tools</h3><h4>Extensions</h4><ul><li><a href="https://chrome.google.com/webstore/detail/axe/lhdoppojpmngadmnindnejefpokejbdd">axe</a> by Deque (Chrome)</li><li><a href="https://chrome.google.com/webstore/detail/wave-evaluation-tool/jbbplnpkjmmeebjpijfedlgcdilocofh">WAVE Evaluation Tool</a> by WebAIM (Chrome)</li></ul><h4>Web apps</h4><ul><li><a href="https://webaim.org/resources/contrastchecker/">Color Contrast Checker</a> by WebAIM</li></ul><h3>Library/Framework</h3><h4>React</h4><ul><li><a href="https://reactjs.org/docs/accessibility.html">Accessibility</a> by React</li><li><a href="https://stackoverflow.com/a/35707795/8486161">Using </a><a href="https://stackoverflow.com/a/35707795/8486161">onKeyPress example</a> (StackOverflow)</li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7c98965d7228" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Refactoring a render prop with hooks]]></title>
            <link>https://medium.com/@seanmcp/refactoring-a-render-prop-with-hooks-fc22ed537199?source=rss-5ce6c0e94b9b------2</link>
            <guid isPermaLink="false">https://medium.com/p/fc22ed537199</guid>
            <category><![CDATA[render-props]]></category>
            <category><![CDATA[react-hook]]></category>
            <category><![CDATA[react]]></category>
            <category><![CDATA[how-to]]></category>
            <dc:creator><![CDATA[Sean McPherson]]></dc:creator>
            <pubDate>Thu, 25 Oct 2018 19:11:01 GMT</pubDate>
            <atom:updated>2018-10-25T19:11:01.269Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Wg8yOr3uXZqSAO09kB6rHQ.png" /></figure><p>Just a few weeks ago, <a href="https://medium.com/@seanmcp/how-to-create-a-render-prop-component-aa3ff54443e6">I published a guide on creating render props components</a>. Today, at React Conf 2018, <a href="https://reactjs.org/docs/hooks-intro.html">the React team announced “Hooks”</a>, a new feature proposal in React v16.7.0-alpha, that will change the way we think about components.</p><p>Hooks serve as a method for abstracting state-based logic and lifecycle methods into reusable functions. These hooks replace a number of the most common use cases for render props.</p><p>So let’s look at how to convert a simple render prop component into a hook!</p><h3>The old: render prop</h3><p>In my previous article, we created a render prop component called “Open” that kept track of an open/close state and shared a method to change it. Here’s the code:</p><pre>import React from &#39;react&#39;</pre><pre>export default class Open extends React.Component {<br>    state = { isOpen: false }</pre><pre>toggle = () =&gt; this.setState({ isOpen: !this.state.isOpen })</pre><pre>render() {<br>        const renderProps = {<br>            isOpen: this.state.isOpen,<br>            toggle: this.toggle<br>        }</pre><pre>return typeof this.props.children === &#39;function&#39;<br>            ? this.props.children(renderProps)<br>            : this.props.children<br>    }<br>}</pre><p>Open could then be implemented in typical render prop fashion:</p><pre>export const App = () =&gt; (<br>    &lt;Open&gt;<br>        {openProps =&gt; (<br>            &lt;div className=&quot;app&quot;&gt;<br>                {openProps.isOpen<br>                    &amp;&amp; &lt;NewMenu toggle={openProps.toggle} /&gt;}<br>                &lt;main&gt;<br>                    &lt;button<br>                        onClick={openProps.toggle}<br>                        type=&quot;button&quot;<br>                    &gt;<br>                        MENU<br>                    &lt;/button&gt;<br>                    &lt;Welcome /&gt;<br>                &lt;/main&gt;<br>            &lt;/div&gt;<br>        )}<br>    &lt;/Open&gt;<br>)</pre><p>Not bad, but let’s refactor this with hooks.</p><h3>The new: hook</h3><p>React’s Hook API allows us to implement state on purely functional components. Let’s create it one step at a time:</p><h4>1. useState</h4><p>Before we get to that, we’re going to name our function useOpen. Prefacing hooks with use is a convention the React team prefers. Now, we’ll import useState function from React:</p><pre>import { useState } from &#39;react&#39;</pre><pre>function useOpen() {<br>    const [isOpen, setIsOpen] = useState(false)<br>    // isOpen is initialized to the passed value: false<br>    // setIsOpen is a function that can update the value</pre><pre>    return { isOpen, setIsOpen }<br>}</pre><p>We call useState and pass it an initial value. This function returns an array with the value and a function for updating that value. To access these data, we’ll create variables by <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Destructuring_assignment#Array_destructuring">destructuring the array</a> returned by useState.</p><p>At this point, isOpen is assigned to false and setIsOpen is a function that is waiting to update that value. Finally, we return those variables in an object.</p><h4>2. Create “method”</h4><p>Our render prop had one method to toggle isOpen between true and false. We can implement the same functionality, but with a basic function:</p><pre>import { useState } from &#39;react&#39;</pre><pre>function useOpen() {<br>    const [isOpen, setIsOpen] = useState(false)<br>    function toggle {<br>        setIsOpen(!isOpen)<br>    }</pre><pre>    return { isOpen, toggle }<br>}</pre><p>The toggle function calls the set function provided by useState and provides the opposite value of isOpen. Then, we return toggle instead of setIsOpen.</p><p>Now we can set it all up!</p><h4>3. Implement useOpen</h4><p>First, we have to remove all the references to the Open and all associated nesting in our App component. Then, we’ll:</p><ol><li>Import useOpen</li><li>Create our variables by calling useOpen</li><li>Remove all references to openProps</li></ol><p>Here’s what we’re left with:</p><pre>import useOpen from &#39;./hooks/useOpen&#39;</pre><pre>export const App = () =&gt; {<br>    const { isOpen, toggle } = useOpen()<br>    return (<br>        &lt;div className=&quot;app&quot;&gt;<br>            {isOpen<br>                &amp;&amp; &lt;NewMenu toggle={toggle} /&gt;}<br>            &lt;main&gt;<br>                &lt;button<br>                    onClick={toggle}<br>                    type=&quot;button&quot;<br>                &gt;<br>                    MENU<br>                &lt;/button&gt;<br>                &lt;Welcome /&gt;<br>            &lt;/main&gt;<br>        &lt;/div&gt;<br>    )<br>}</pre><p>No more parent components, passed functions, or faux-nesting. Just grabbing variables from a function and referencing them in the return of your component.</p><p>That’s it! We’ve recreated a basic render prop component as a hook.</p><h3>Summary</h3><p>Hooks are a “new feature <strong>proposal</strong>” and therefore are not ready for implementation in an app. That being said, the React team sees hooks and class-less components as the future of the library. <a href="https://reactjs.org/docs/hooks-intro.html#motivation">Read here for the motivation behind this feature and the future direction of React</a>.</p><p>While the syntax of hooks are less intuitive than render props, the implementation is more straightforward.</p><p>For a more detailed explanation of hooks, <a href="https://reactjs.org/docs/hooks-custom.html">checkout the official docs</a> (and <a href="https://twitter.com/dan_abramov">Dan Abramov</a>’s and <a href="https://twitter.com/ryanflorence">Ryan Florence</a>’s talks at React Conf 2018).</p><p>Hopefully that helped! Let me know what you think about React’s new hooks in the comments below.</p><p>Happy coding!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=fc22ed537199" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to create a render prop component]]></title>
            <link>https://medium.com/@seanmcp/how-to-create-a-render-prop-component-aa3ff54443e6?source=rss-5ce6c0e94b9b------2</link>
            <guid isPermaLink="false">https://medium.com/p/aa3ff54443e6</guid>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[render-props]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[react]]></category>
            <category><![CDATA[how-to]]></category>
            <dc:creator><![CDATA[Sean McPherson]]></dc:creator>
            <pubDate>Tue, 09 Oct 2018 16:16:02 GMT</pubDate>
            <atom:updated>2018-10-09T16:16:02.695Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_Wbx4vb_v8FbeLeSgLL1bA.png" /></figure><p>It’s been a year since Michael Jackson published <a href="https://cdb.reacttraining.com/use-a-render-prop-50de598f11ce">“Use a Render Prop!”</a> here on Medium, which encouraged using render props instead of higher order components (HOCs). Since then, “render props” has grown into a bigger and bigger buzzword in the React community.</p><p>If you are new to React or just new to the concept, the look of a render prop can be a little daunting. Checkout <a href="https://github.com/drcmda/react-spring">this example</a> from react-spring&#39;s documentation:</p><pre>import { Spring } from &#39;react-spring&#39;<br><br>&lt;Spring from={{ opacity: 0 }} to={{ opacity: 1 }}&gt;<br>  {styles =&gt; &lt;div style={styles}&gt;i will fade in&lt;/div&gt;} // &lt;-- Here<br>&lt;/Spring&gt;</pre><p>If that makes perfect sense to you, awesome 🎉! Skip this article and get back to coding. If not, don’t worry; I didn’t get it at first either. Stick around, and I’ll attempt to break down render props and show you how to make your own.</p><h3>Background</h3><h4>What is a render prop?</h4><p>At its core, render prop is <a href="https://reactjs.org/docs/render-props.html">“a simple technique for sharing code between React components using a prop whose value is a function.”</a> Instead of passing a string or object, you pass a function as a prop.</p><pre>&lt;Name<br>    renderProp={() =&gt; &quot;Passing a function as a prop!&quot;}<br>/&gt;</pre><p>The code above won’t accomplish much — the arrow function just returns a string — but it introduces a new paradigm. What if, within Name we pass some data to our props.renderProp function?</p><pre>const Name = (props) =&gt; {<br>    const name = &#39;Sean&#39;<br>    return props.renderProp(name)<br>}</pre><p>When Name renders, it calls props.renderProp and passes some data; in this case, a string with my name.</p><p>We have designed our Name component with the sole purpose of storing the name data and passing it on to the props.renderProps function. The is the secret sauce that makes render props so powerful.</p><p>Going back to the implementation of Name, the function I pass to renderProp can look for this data as a parameter:</p><pre>&lt;Name<br>    renderProp={(name) =&gt; `Hello, my name is ${name}!`}<br>/&gt;</pre><p>When Name is called, it creates variable name with the value ‘Sean’, then calls the props.renderProp function and passes name. Finally, it returns a string that reads Hello, my name is Sean!.</p><p>But we aren’t just limited to strings; this is React! You can return JSX in your function to render new elements in the VirtualDOM:</p><pre>&lt;Name<br>    renderProp={(name) =&gt; &lt;span&gt;Hello, my name is {name}!&lt;/span&gt;}<br>/&gt;</pre><p>That’s it! Render props provide us a method of passing props from a parent component to a child via function props. Using these same principles, we can create useful and reusable “logic” components to implement in any application.</p><blockquote>Note: I called our prop renderProp, but there is nothing special about that name; you can use whatever name you want. I’ll give you my recommendation for passing function props later on.</blockquote><h4>What does render props replace?</h4><p>In most use cases, render props will replace HOCs. If we wanted to accomplish the above example with an HOC, we might use something like this:</p><pre>const withName = (Component) =&gt; &lt;Component name=&quot;Sean&quot; /&gt;</pre><p>Then our parent component would be passed to withName, usually during the export. Once that is done, we could access props.name and render our greeting:</p><pre>const App = (props) =&gt; (<br>    &lt;span&gt;Hello, my name is {props.name}!&lt;/span&gt;<br>)</pre><pre>export default withName(App)</pre><p>This works, and certainly has <a href="https://react-redux.js.org/docs/connect-extracting-data-with-mapstatetoprops">its use cases</a>, but can introduce issues such as naming collisions. I recommend <a href="https://cdb.reacttraining.com/use-a-render-prop-50de598f11ce">Jackson’s article for a more detailed dive into render props and HOCs</a>.</p><h3>How To</h3><blockquote>Note: Facebook provides an <a href="https://reactjs.org/docs/render-props.html">introduction to render props in their React documentation</a>. It is a useful resource, but their example was contrived and therefore difficult to reapply to new scenarios. Here I will provide a tried-and-true example that I have utilized in multiple projects.</blockquote><h4>Setting up our app</h4><p>Let’s imagine you’re creating an application with drawer menu. Most of the time the menu is hidden, but when you hit a toggle button, the menu opens. Within the menu, you want to have an accordion that reveals additional links when open. In order to accomplish this, you might do something like this:</p><pre>export class App extends React.Component {<br>    state = {<br>        menuIsOpen: false<br>    }</pre><pre>    render() {<br>        return (<br>            &lt;div className=&quot;app&quot;&gt;<br>                {this.state.menuIsOpen<br>                    &amp;&amp; &lt;Menu toggle={this.toggle} /&gt;}<br>                &lt;main&gt;<br>                    &lt;button onClick={this.toggle} type=&quot;button&quot;&gt;<br>                        MENU<br>                    &lt;/button&gt;<br>                &lt;/main&gt;<br>            &lt;/div&gt;<br>        )<br>    }</pre><pre>    toggle = () =&gt; this.setState(<br>        { menuIsOpen: !this.state.menuIsOpen }<br>    )<br>}</pre><p>We made App a stateful component and keep track of a boolean for the menu. Additionally, we added a toggle method to open and close the menu.</p><p>Now we need to create Menu:</p><pre>export class Menu extends React.Component {<br>    state = {<br>        socialsIsOpen: false<br>    }</pre><pre>    render() {<br>        return (<br>            &lt;div className=&quot;menu&quot;&gt;<br>                &lt;button onClick={this.props.toggle} type=&quot;button&quot;&gt;<br>                    CLOSE<br>                &lt;/button&gt;<br>                &lt;h2&gt;Menu&lt;/h2&gt;<br>                &lt;button onClick={this.toggle} type=&quot;button&quot;&gt;<br>                    SOCIALS {this.state.socialsIsOpen ? &#39;▴&#39; : &#39;▾&#39;}<br>                &lt;/button&gt;<br>                {this.state.socialsIsOpen &amp;&amp; &lt;Socials /&gt;}<br>            &lt;/div&gt;<br>        )<br>    }</pre><pre>    toggle = () =&gt; this.setState(<br>        { socialsIsOpen: !this.state.socialsIsOpen }<br>    )<br>}</pre><p>Look familiar? We <strong>reused the state from </strong><strong>App </strong>(🚩 red flag no 1)<strong> </strong>so that we could keep track of whether or not to display our Socials component (just an unordered list of links). Menu needed to be toggled too, so we <strong>copy and pasted the method from </strong><strong>App </strong>(🚩 red flag no. 2).</p><p>This works, but there are two main problems:</p><ol><li><strong>👎 Not DRY</strong>: In order to achieve the same function in two different components, I needed to repeat myself by copying and pasting the state and toggle method.</li><li><strong>👎 Not extensible</strong>: Imagine I want to add another toggle feature to my app. What do I need to do? Copy and paste the necessary state and method again, which compounds my problem.</li></ol><p>Fortunately, we can solve both of these problems easily with a simple render prop component.</p><h4>Creating a render prop</h4><p>The purpose of our render prop component will be to manage an open and closed state. It will also need a method to toggle the state like the examples above. Then it will take the state and method and pass it as arguments to a prop.</p><p>My preference for render props is to use a Component&#39;s children prop. This allows us to utilize opening and closing tags — a familiar convention in React — and makes indentation a little more manageable.</p><p>Our render prop component looks like this.</p><pre>import React from &#39;react&#39;</pre><pre>export default class Open extends React.Component {<br>    state = { isOpen: false }</pre><pre>    toggle = () =&gt; this.setState({ isOpen: !this.state.isOpen })</pre><pre>    render() {<br>        const renderProps = {<br>            isOpen: this.state.isOpen,<br>            toggle: this.toggle<br>        }</pre><pre>        return typeof this.props.children === &#39;function&#39;<br>            ? this.props.children(renderProps)<br>            : this.props.children<br>    }<br>}</pre><p>Just like the previous examples, I am keeping track of an “open” state and toggling it with a method. Here I simplified the name of the boolean in the state to isOpen because our component doesn’t care what is and is not open. The only thing Open cares about is whether or not isOpen is true or false.</p><blockquote>Render props components do not care about presentational logic. Their sole purpose is to keep track of simple bits of data and pass it on.</blockquote><p>The toggle method is the same as previous examples.</p><p>Within the render method, I create a renderProps object with which I can pass on the current value of isOpen and my toggle method.</p><p>Finally I do a quick typeof check while returning. If this.props.children is a function, as I expect, then it will pass renderProps as an argument. If not, then it will fail softly by simply returning this.props.children.</p><p>You can optionally do some type-checking to ensure that children is a function, but I chose not to add an additional library here.</p><h4>Implementing our render prop</h4><p>Now that we have abstracted the open/close logic to Open, we can clean up our App component:</p><pre>export const App = () =&gt; (<br>    &lt;Open&gt;<br>        {openProps =&gt; (<br>            &lt;div className=&quot;app&quot;&gt;<br>                {openProps.isOpen<br>                    &amp;&amp; &lt;NewMenu toggle={openProps.toggle} /&gt;}<br>                &lt;main&gt;<br>                    &lt;button<br>                        onClick={openProps.toggle}<br>                        type=&quot;button&quot;<br>                    &gt;<br>                        MENU<br>                    &lt;/button&gt;<br>                    &lt;Welcome /&gt;<br>                &lt;/main&gt;<br>            &lt;/div&gt;<br>        )}<br>    &lt;/Open&gt;<br>)</pre><p>We pass Open a child function that looks for our render props. Now I just need to switch out all references to this.state.menuIsOpen and this.toggle to refer to openProps.</p><p>Notice that App no longer needs a state; we can convert it to a functional component and let Open do all the work.</p><p>Next, let’s do the same thing with Menu:</p><pre>export const Menu = props =&gt; (<br>    &lt;Open&gt;<br>        {openProps =&gt; (<br>            &lt;div className=&quot;menu&quot;&gt;<br>                &lt;button onClick={props.toggle} type=&quot;button&quot;&gt;<br>                    CLOSE<br>                &lt;/button&gt;<br>                &lt;h2&gt;Menu&lt;/h2&gt;<br>                &lt;button onClick={openProps.toggle} type=&quot;button&quot;&gt;<br>                    SOCIALS {openProps.isOpen ? &#39;▴&#39; : &#39;▾&#39;}<br>                &lt;/button&gt;<br>                {openProps.isOpen &amp;&amp; &lt;Socials /&gt;}<br>            &lt;/div&gt;<br>        )}<br>    &lt;/Open&gt;<br>)</pre><p>Likewise, we were able to simplify Menu by converting it to a functional component as well. This may not seem like a big deal now, but it will be increasingly important as an application scales.</p><blockquote>The fewer states and methods that you need to manage, the better.</blockquote><p>You can see our render prop live, in all its glory, <a href="https://codesandbox.io/s/x5j1pl90o">here on CodeSandbox</a>:</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fcodesandbox.io%2Fembed%2Fx5j1pl90o&amp;url=https%3A%2F%2Fcodesandbox.io%2Fs%2Fx5j1pl90o&amp;image=https%3A%2F%2Fcodesandbox.io%2Fapi%2Fv1%2Fsandboxes%2Fx5j1pl90o%2Fscreenshot.png&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=codesandbox" width="1000" height="500" frameborder="0" scrolling="no"><a href="https://medium.com/media/d1f75426ede71417b1b5372190b09212/href">https://medium.com/media/d1f75426ede71417b1b5372190b09212/href</a></iframe><h3>Review</h3><p>The render props technique is a great way to abstract reusable logic into specialized components. These components pass their logic/data/methods as arguments to functions passed as props.</p><p>Utilizing render props components solves the two problems above:</p><ol><li><strong>👍 DRY</strong>: The only code repeated is &lt;Open&gt;. You’ll never have to write another toggle method.</li><li><strong>👍 Extensible</strong>: Next time you want to add opening and closing to your app, all you need to add is Open.</li></ol><p>Now that we’ve reviewed, let’s take a look back at that original example from react-spring:</p><pre>import { Spring } from &#39;react-spring&#39;</pre><pre>&lt;Spring from={{ opacity: 0 }} to={{ opacity: 1 }}&gt;<br>  {styles =&gt; &lt;div style={styles}&gt;i will fade in&lt;/div&gt;} // &lt;-- Here<br>&lt;/Spring&gt;</pre><p>We can see that this Spring component is passed a this.props.children function. It then gives some data, in this case a style object, to that function as an argument. Finally, those styles are applied to the div.</p><p>Not bad, right? Now that you’ve mastered render props, make sure to <a href="https://github.com/jaredpalmer/awesome-react-render-props">check out this curated list</a> of awesome render props. In the words of Captain Planet, “The power is yours!”</p><p>I hope this article helped; I know I learned a lot while writing it. Let me know if you have any questions about or problems with the code below.</p><p>Happy coding!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=aa3ff54443e6" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[ Deploy your code!]]></title>
            <link>https://medium.com/@seanmcp/deploy-your-code-25b4bc19088d?source=rss-5ce6c0e94b9b------2</link>
            <guid isPermaLink="false">https://medium.com/p/25b4bc19088d</guid>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[deployment]]></category>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[front-end-development]]></category>
            <category><![CDATA[github]]></category>
            <dc:creator><![CDATA[Sean McPherson]]></dc:creator>
            <pubDate>Mon, 10 Sep 2018 16:53:38 GMT</pubDate>
            <atom:updated>2018-09-10T16:55:23.649Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_9sfjL1W97gNTdMVbAh_hw.jpeg" /><figcaption>A quick guide to deploying your code (Photo by <a href="https://unsplash.com/photos/OHOU-5UVIYQ?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">SpaceX</a> on <a href="https://unsplash.com/search/photos/rocket?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Unsplash</a>)</figcaption></figure><p>Imagine the following scenario: you are a self-learned programmer or recent coding bootcamp graduate who is struggling to find a first development job. You’ve been learning a lot, working on projects, and have some good examples on your GitHub, but you can’t seem to get through the screening process to an interview.</p><p>What can you do? How can you better position yourself to get a job in the industry?</p><h3>Set yourself apart</h3><p>Before I sound like a snake-oil salesman, I want to admit: there are many reasons why you might be having trouble finding a first job. You might have a bad resume, be applying for the wrong positions, or be looking in the wrong market.</p><p>But there is one sure-fire way to increase your chances of breaking through the noise: <strong>deploy your code</strong>.</p><h3>The hard truth</h3><p>It is crucial as a job seeker to showcase your new coding skills on a platform like GitHub. Add repositories, commit often, pin your best work, and make sure to create a property description and README. A polished GitHub account communicates to an potential employer that you are a professional who is serious about coding.</p><p>Despite all that, the reality is that no hiring manager is going to clone your repositories just to check out your projects. Sure, s/he might click through and scan the code, but no one has time to do that for every project of every applicant. So you need to do that work for them. You need to deploy it.</p><blockquote>No hiring manager is going to clone your repositories just to check out your projects.</blockquote><h3>Uh… “deploy”?</h3><p>The the world of software development, deployment “encompasses all the processes involved in getting new software or hardware up and running properly in its environment” (<a href="https://whatis.techtarget.com/definition/deploy">TechTarget</a>). In more simple terms, deploying your code means getting it up and running for other people to use.</p><p>In years past, deploying code might have been as simple as uploading a few HTML, CSS, and JS files to a web host (this still might be a good solution for you, depending on the project). Today, chances are you will want a more robust environment that can run node.js in deployment.</p><h3>Before your eyes glaze over: take a deep breath.</h3><p>There are services out there that make deploying projects quick and painless. Here are a few options that can help you get your projects up and running for the world to see.</p><h3>CLI Deployment</h3><p>There are a few CLI (command line interface) options for rapidly deploying your code.</p><h4>Surge</h4><p>Surge is a simple, single command for web publishing. They boast the ability to publish HTML, CSS, and JS for free, without leaving the command line.</p><p><strong>1. Set up</strong></p><pre>$ npm i -g surge</pre><p><strong>2. Navigate to a project</strong></p><pre>$ cd my-web-project<br>$ ls<br>index.html    main.js    styles.css</pre><p><strong>3. Deploy!</strong></p><pre>$ surge</pre><p>Done and done! Surge gives you a link where you can view your project in deployment.</p><p>Surge also offers the ability to customize your subdomain on surge.sh, and even supports a custom url (<em>e.g.</em> your-name.com). Checkout for information on <a href="https://surge.sh/">surge.sh</a>.</p><h4>now</h4><p>Now is created by the folks at ZEIT for getting your applications to the cloud with ease, speed and reliability. Any project with a package.json or Dockerfile can be deployed with the `now` command.</p><p><strong>1. Set up</strong></p><pre>$ npm i -g now</pre><p><strong>2. Navigate to a project</strong></p><pre>$ cd my-node-project<br>$ ls<br>package.json   index.js</pre><p><strong>3. Deploy!</strong></p><pre>$ now</pre><p>That’s it! With one word, now too generates a url for the live project.</p><p>Now has some cool features that utilize githooks for redeployment, and a desktop client to better visualize and manage your projects. Checkout now out at <a href="https://zeit.co/now">zeit.co/now</a>.</p><h3>GitHub Pages</h3><p>GitHub Pages allows you to host personal, organization, or project pages directly from a GitHub repository. The service is both easy, useful, and popular — utilized by <a href="http://casesandberg.github.io/react-color/">individuals</a><a href="http://casesandberg.github.io/react-color/,">,</a> <a href="https://reasonml.github.io/reason-react/en/">communities</a><a href="https://reasonml.github.io/reason-react/en/,">,</a> and <a href="https://facebook.github.io/react-native/">companies</a> alike.</p><blockquote>Note: GitHub Pages is a static site hosting service and doesn’t support server-side code such as PHP, Ruby, or Python. Pages are also subject to <a href="https://help.github.com/articles/what-is-github-pages/#usage-limits">some usage limits</a><a href="https://help.github.com/articles/what-is-github-pages/#usage-limits.">.</a></blockquote><p>Once deployed, sites on GitHub Pages are conveniently available at https://&lt;username&gt;.github.io/&lt;repo&gt;, which is a great way to keep your applications <a href="https://www.quora.com/What-does-it-mean-when-something-is-on-brand-in-marketing-and-branding">on brand</a>.</p><h4>Static websites</h4><p>For a static website — just HTML, CSS, and JavaScript — GitHub Pages can be activated with just two clicks.</p><p><strong>1. Go to “Settings”</strong></p><p>Go to your repository’s settings and scroll down to the “GitHub Pages” section.</p><p><strong>2. Select a branch</strong></p><p>In the dropdown, select the branch that you wish to deploy. Then hit “Save”.</p><p>And that’s it! Your site will be live at https://&lt;username&gt;.github.io/&lt;repo&gt;.</p><p>For a more detailed description of deploying a static website to GitHub Pages, <a href="https://github.com/SeanMcP/tutorial-deploy-gh-pages">check out this tutorial (with a live example)</a>.</p><h4>React</h4><p>GitHub Pages is also a great solution for hosting simple React applications. Facebook provides a <a href="https://github.com/facebook/create-react-app/blob/master/packages/react-scripts/template/README.md#github-pages">great step-by-step tutorial</a> for deploying a create-react-app on GitHub Pages.</p><p>By adding gh-pages to your application and a few scripts to the application.json, you can deploy your React app with a simple command:</p><pre>npm run deploy</pre><p>I’ve used the tutorial (which is included in the create-react-app README.md) to deploy most of my React apps.</p><h3>Other options</h3><p>If you are looking to host a back-end application or just looking for more robust management features, here are some additional deployment options:</p><h4>Netlify</h4><p>Netlify bills themselves as a “all-in-one platform for automating modern web projects.” They seamlessly sync with hosted respositories and deploy after a simple build configuration. I have used Netlify before and was super impressed with their free features.</p><p>To give Netlify a try, start with <a href="https://www.netlify.com/blog/2017/01/31/best-practices-getting-started-with-netlify/">their guide for getting started</a> on the platform.</p><h4>Heroku</h4><p>Heroku is a cloud application platform for developers, teams, and businesses of all sizes to deploy, manage, and scale apps. They have tons of features and price plans from free to enterprise.</p><p>To get started on Heroku, check out <a href="https://devcenter.heroku.com/start">their Dev Center Guide</a>.</p><h3>Web Hosting</h3><p>Sometimes the best deployment solution for your project will be good old-fashioned web hosting. A web host provides you space on a server to store files which they’ll serve up when a user hits your IP or URL address.</p><p>In reality, all the aforementioned services are providing web hosting, but I’m talking about classic web hosts like <a href="https://mediatemple.com/">MediaTemple</a> or <a href="https://bluehost.com/">BlueHost</a>.</p><p>Working with a web host can provide valuable “webmaster” experience to any web developer, even if it comes at the cost of $5–10 per month. Plus, they most provide custom email options so you can have name@yourdomain.com.</p><p>I currently use <a href="https://greengeeks.com/">GreenGeeks</a>, but I have used multiple web hosts in the past; they all provide basically the same service. Pick the provider that feels best to you.</p><p>In addition to the web hosts linked above, also checkout: <a href="https://dreamhost.com/">DreamHost</a>, and <a href="https://hostgator.com/">HostGator</a>.</p><h3>READ THIS AFTER DEPLOYING YOUR CODE</h3><p>Congrats; you did it! Take a moment and celebrate. Then, copy that beautiful URL, send it to your friends and family, and put it two very important places: GitHub and your resume.</p><h4>GitHub</h4><p>Go to the project’s repository and click “Edit” to the top and right. In the “Website” box, paste your project’s live URL, then save. Now anyone who finds themselves looking at your repo (e.g. hiring managers) will be able to easily click the link and see the code in action.</p><blockquote>Site note: If you haven’t added a description to your repository, do that now too. Keep it short and descriptive (and feel free to use emojis 👍).</blockquote><h4>Resume</h4><p>Your resume should have a separate section to feature your projects. In this section, you should include the name, description, and repo link for your best work. Now add the deployed URL to the project.</p><p>Make sure your word processor doesn’t automatically turn your URL into a hyperlink. Hiring managers won’t be able to click a piece of paper (duh), and the default blue underlined text won’t look professional on your resume.</p><h3>tl;dr</h3><p>Finding a first developer job is hard, but deploying your code can increase your chances of breaking through. Using any of the solutions above to deploy your code will give you valuable developer experience and give you a leg up on your job hunting competition.</p><p>I hope all that helps! Let me know in the comments below if there are any deployment resources that you think I should add to this list.</p><p>Happy coding!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=25b4bc19088d" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>