<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>Forem: Red Cap Tom</title>
    <description>The latest articles on Forem by Red Cap Tom (@redcaptom).</description>
    <link>https://forem.com/redcaptom</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F387259%2F83977a7b-0f07-46c6-be44-1f970a2eaa96.png</url>
      <title>Forem: Red Cap Tom</title>
      <link>https://forem.com/redcaptom</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/redcaptom"/>
    <language>en</language>
    <item>
      <title>Shopify App From Scratch #12 - User Interface 2</title>
      <dc:creator>Red Cap Tom</dc:creator>
      <pubDate>Sun, 14 Jun 2020 20:43:44 +0000</pubDate>
      <link>https://forem.com/redcaptom/shopify-app-from-scratch-12-user-interface-2-3327</link>
      <guid>https://forem.com/redcaptom/shopify-app-from-scratch-12-user-interface-2-3327</guid>
      <description>&lt;h2&gt;
  
  
  Deprecation Notice
&lt;/h2&gt;

&lt;p&gt;Yeah, yeah, I know. I hate it too when people abandon tutorial series mid-way. But, due to (exciting!) circumstances, I'm calling it quits for now.&lt;/p&gt;

&lt;p&gt;I'm thinking of just dropping a link to the full repo here - it's a mess, but it's something you guys can chew on instead of my empty promises.&lt;/p&gt;

&lt;p&gt;If you'd like me to drop it here - let me know at &lt;a href="mailto:hey@redcaptom.com"&gt;hey@redcaptom.com&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;And, just sayin', I had a BLAST doing this. If you know something - anything - about technology, take the time to write it down as a tutorial series. You will get SO, SO much value out of it, you can't even believe it.&lt;/p&gt;

&lt;p&gt;Until we meet again - RCT :)&lt;/p&gt;

&lt;h2&gt;
  
  
  The Video (Scroll down for the article)
&lt;/h2&gt;

&lt;p&gt;Coming soon!&lt;/p&gt;

&lt;h2&gt;
  
  
  More User Interface
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://github.com/redcaptom/countries-we-ship-to-button/tree/f7732304331943c4ebc83207a047b1bfd661a3db"&gt;Git repo link&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Alright, so we are currently here:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--5WTaBL1d--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/qossf58dxvv4kegvl3pb.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--5WTaBL1d--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/qossf58dxvv4kegvl3pb.png" alt="Empty &amp;amp; Full"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This is nice, but it doesn't actually lets the user &lt;em&gt;choose&lt;/em&gt; between the two buttons, now, does it? We'd need to add some sort of input element to allow the user to pick a button variant.&lt;/p&gt;

&lt;p&gt;Since this is an OR relation, i.e. you have to pick one - and exactly one - variant of button, a &lt;a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/radio"&gt;radio button&lt;/a&gt; is a great fit. Shopify actually provides us with a &lt;a href="https://polaris.shopify.com/components/forms/radio-button"&gt;Radio Button&lt;/a&gt; component that has all sorts of niceties to it:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight jsx"&gt;&lt;code&gt;&lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;RadioButton&lt;/span&gt;
  &lt;span class="na"&gt;label&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"The text that appears right next to the button"&lt;/span&gt;
  &lt;span class="na"&gt;helpText&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"Greyed-out subtext"&lt;/span&gt;
  &lt;span class="na"&gt;checked&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;A boolean value to indicate whether the button is checked or not&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;
  &lt;span class="na"&gt;id&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"An HTML element id, used for selection (must be unique)"&lt;/span&gt;
  &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"An HTML element name used for identification (can be repeated)"&lt;/span&gt;
  &lt;span class="na"&gt;onChange&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;
    &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;A callback function, that is triggered once the radio button is changed (i.e. marked / unmarked)&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;
  &lt;span class="si"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;/&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Let's talk a little bit about this, since this is the first time we're observing an element that is not very simple. Look at all the props we're providing the componenet (&lt;code&gt;label&lt;/code&gt;, &lt;code&gt;helpText&lt;/code&gt;, &lt;code&gt;checked&lt;/code&gt; etc.) - I've added a small sentence explaing what each of them does. There are two props - &lt;code&gt;checked&lt;/code&gt; and &lt;code&gt;onChange&lt;/code&gt; - that get &lt;code&gt;{}&lt;/code&gt; as inputs and not just text. Inside those &lt;code&gt;{}&lt;/code&gt; we can input whatever JavaScript we want, but they expect to get a boolean and a callback function, respectively. But, hold back one moment. Why do we need a React component for a radio button? We already have &lt;code&gt;&amp;lt;input type="radio"&amp;gt;&lt;/code&gt;, right? Let's explore this for a second.&lt;/p&gt;

&lt;p&gt;A &lt;a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/radio"&gt;normal radio button&lt;/a&gt; (i.e. &lt;code&gt;&amp;lt;input type="radio"&amp;gt;&lt;/code&gt;) already has a &lt;code&gt;checked&lt;/code&gt; attribute and a &lt;code&gt;change&lt;/code&gt; event, that can replace the &lt;code&gt;checked&lt;/code&gt; and &lt;code&gt;onChange&lt;/code&gt; props. We can totally use those without having to wrap the button in a component. But, the Polaris design system would like to &lt;strong&gt;standardize&lt;/strong&gt; the way radio buttons are used in Shopify Apps. Therefore, the &lt;code&gt;RadioButton&lt;/code&gt; component encapsulates all the &lt;a href="https://github.com/Shopify/polaris-react/blob/master/src/components/RadioButton/RadioButton.scss"&gt;styles&lt;/a&gt; Shopify would like you to use with the button (padding, color of the bullet in the button, color of the surroundinc circle etc.). It also allows for a somewhat more convienent wrapper around features that are often used together (like &lt;code&gt;label&lt;/code&gt; that removes the need for a &lt;code&gt;&amp;lt;label&amp;gt;&lt;/code&gt; tag and &lt;code&gt;helpText&lt;/code&gt; that expands the normal label with optional subtext).&lt;/p&gt;

&lt;p&gt;The reason why &lt;code&gt;onChange&lt;/code&gt; is also a &lt;code&gt;RadioButton&lt;/code&gt; property has to do with the way React sees the world. In React, everything is interactive - an action in one element is expected to trigger something in another element, or maybe even in the backend of the application. The &lt;code&gt;change&lt;/code&gt; event (in the original &lt;code&gt;&amp;lt;input type="radio"&amp;gt;&lt;/code&gt;) was created for just this purpose - to be the main source of interactivity for your radio button (when its value changes, do something - i.e. trigger a callback function). But, in practice, getting this functionality of events to work across browsers has been historically &lt;strong&gt;hard&lt;/strong&gt;. React created a &lt;a href="https://stackoverflow.com/a/48879414"&gt;new type of event&lt;/a&gt;, that "wraps around" the original event, and that is why we have a special &lt;code&gt;onChange&lt;/code&gt; property inside the component. This is not the only reason, of course, but to me is the most.... comfortable one. If Dan Abramov ever reads this, and I happen to be wrong (which I sometimes am, it appears) - please accept my sincere apologies and make a comment for me to fix this. :P&lt;/p&gt;

&lt;p&gt;Back to business - what do we want to happen when the button changes? Well, we want to first &lt;em&gt;know&lt;/em&gt; that it did. Which means we need to &lt;em&gt;store&lt;/em&gt; that infomration somewhere. Luckily, we can use &lt;em&gt;state&lt;/em&gt; in our &lt;code&gt;App&lt;/code&gt; component to keep track of what's going on inside the page!&lt;/p&gt;

&lt;h4&gt;
  
  
  A Note on Redux
&lt;/h4&gt;

&lt;p&gt;You will note that I, much like the offical &lt;a href="https://shopify.dev/tutorials/build-a-shopify-app-with-node-and-react"&gt;Shopify Tutorial&lt;/a&gt;, chose to forego the use of a (very) popular JavaScript library called &lt;a href="https://redux.js.org/"&gt;Redux&lt;/a&gt;. Redux allows you to have a &lt;em&gt;central&lt;/em&gt;, instead of a &lt;em&gt;distributed&lt;/em&gt;, location for your state. A state of a component is some information being kept in it about.... whatever, and is notriously difficult to manage as your apps get more and more complicated.&lt;/p&gt;

&lt;p&gt;I can honestly say that the app I'm building here is just not complicated enough to justify the use of Redux, or any other central state management library. Therefore, I "bear" the complexity, and choose to manage the state myself. This might seem like I'm doing a lot of hacks to get the information around, but for the sake of simplicity I think it's the way to go.&lt;/p&gt;

&lt;p&gt;So before we add the radio button, let's make sure to add state properties that account for &lt;em&gt;which&lt;/em&gt; button was selected. For this, I am going to correct an oversight that any experience React developer will tell you I made (albeit intentionally) in the beginning: I omitted the &lt;strong&gt;constructor&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;A constructor (as I mentioned in the React Sidestep 3) is a special function in a JavaScript class (and specifically inside React class components) that gets called when an object representing the class is initiated. So let's add it first:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight jsx"&gt;&lt;code&gt;&lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nx"&gt;App&lt;/span&gt; &lt;span class="kd"&gt;extends&lt;/span&gt; &lt;span class="nx"&gt;React&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;Component&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;constructor&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;props&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;super&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;props&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="nx"&gt;render&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;
      &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;AppProvider&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
      ...
      &lt;span class="p"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nc"&gt;AppProvider&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="k"&gt;default&lt;/span&gt; &lt;span class="nx"&gt;App&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;VSCode might throw a "useless constructor" error at you (well, probably a warning - i.e. yellow squiggly lines, and not an error). This is OK - this constructor indeed doesn't do anything. All it does is call the constructor of the class above it with the props that were provided to it (since every React class component extends &lt;code&gt;React.Component&lt;/code&gt;, its constructor is being called with the pops provided for the current constructor). This is an implementation detail that you shouldn't really care about - it's the way React is built.&lt;/p&gt;

&lt;p&gt;The interesting bit comes when we want to provide state to the component. This can happen simply by defining the &lt;code&gt;state&lt;/code&gt; attribute for the current class in the following way:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight jsx"&gt;&lt;code&gt;&lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nx"&gt;App&lt;/span&gt; &lt;span class="kd"&gt;extends&lt;/span&gt; &lt;span class="nx"&gt;React&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;Component&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;constructor&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;props&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;state&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{}&lt;/span&gt;
    &lt;span class="k"&gt;super&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;props&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="nx"&gt;render&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;
      &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;AppProvider&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
        ...
      &lt;span class="p"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nc"&gt;AppProvider&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="k"&gt;default&lt;/span&gt; &lt;span class="nx"&gt;App&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;We now have a place in our component where we can manage our state. Let's add a property inside our state, one that shows which variant of the button has been selected:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight jsx"&gt;&lt;code&gt;&lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nx"&gt;App&lt;/span&gt; &lt;span class="kd"&gt;extends&lt;/span&gt; &lt;span class="nx"&gt;React&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;Component&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;constructor&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;props&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;state&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="na"&gt;buttonType&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;full&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;
    &lt;span class="p"&gt;};&lt;/span&gt;
    &lt;span class="k"&gt;super&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;props&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="nx"&gt;render&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;
      &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;AppProvider&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
        ...
      &lt;span class="p"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nc"&gt;AppProvider&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="k"&gt;default&lt;/span&gt; &lt;span class="nx"&gt;App&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;We define &lt;code&gt;buttonType&lt;/code&gt; to be &lt;code&gt;"full"&lt;/code&gt; upon initialization to provide some sort of default to the user. This means that at first initizliation, the selection box will be the one one with the full button in it. In the future, we will have this value stored in a database, and brought into the application to "remember" the prefence of the user. More about this later.&lt;/p&gt;

&lt;p&gt;We also need to create some function that - when the button's status is changed - chages the value in the state of the component. This is a function that is called when &lt;code&gt;onChange&lt;/code&gt; is called on &lt;code&gt;RadioButton&lt;/code&gt; - i.e. a &lt;strong&gt;callback fucntion&lt;/strong&gt;. Let's call this function &lt;code&gt;handleButtonTypeSelection&lt;/code&gt;, since it handles which type of button is used.&lt;/p&gt;

&lt;p&gt;This function can go in one of &lt;a href="https://reactjs.org/docs/faq-functions.html#bind-in-constructor-es2015"&gt;one&lt;/a&gt; &lt;a href="https://reactjs.org/docs/faq-functions.html#bind-in-render"&gt;of&lt;/a&gt; &lt;a href="https://reactjs.org/docs/faq-functions.html#class-properties-stage-3-proposal"&gt;4&lt;/a&gt; &lt;a href="https://reactjs.org/docs/faq-functions.html#arrow-function-in-render"&gt;places&lt;/a&gt;, which can cause a bit of confusion. I'm choosing to add them as &lt;a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/Arrow_functions"&gt;arrow functions&lt;/a&gt; inside the &lt;code&gt;render&lt;/code&gt; function, like so:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight jsx"&gt;&lt;code&gt;&lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nx"&gt;App&lt;/span&gt; &lt;span class="kd"&gt;extends&lt;/span&gt; &lt;span class="nx"&gt;React&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;Component&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;constructor&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;props&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;state&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="na"&gt;buttonType&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;full&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;
    &lt;span class="p"&gt;};&lt;/span&gt;
    &lt;span class="k"&gt;super&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;props&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="nx"&gt;render&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;handleButtonTypeSelection&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;changedButtonType&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="p"&gt;...&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;
      &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;AppProvider&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
        ...
      &lt;span class="p"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nc"&gt;AppProvider&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="k"&gt;default&lt;/span&gt; &lt;span class="nx"&gt;App&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;I like this option because it feels, to me, like it's simpler once you figure out how arrow functions work like. For most intents and purposes, an arrow function is just another way to write a function - instead of &lt;code&gt;funcName(){}&lt;/code&gt;, we're writing &lt;code&gt;const funcName = () =&amp;gt; {}&lt;/code&gt;. But, there are some places where the arrow function behaves a bit differently than your run-of-the-mill function - and I will warn you about them as they come up. In this case - use the arrow! :)&lt;/p&gt;

&lt;p&gt;Our full function needs to accept the type of button that was selected, and change the state of the component's &lt;code&gt;buttonType&lt;/code&gt; accordingly. As you will see in a moment, this will also check the correct button by changing the &lt;code&gt;checked&lt;/code&gt; prop on each &lt;code&gt;RadioButton&lt;/code&gt; component. Let's put our full function in then:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight jsx"&gt;&lt;code&gt;&lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nx"&gt;App&lt;/span&gt; &lt;span class="kd"&gt;extends&lt;/span&gt; &lt;span class="nx"&gt;React&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;Component&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;constructor&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;props&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;state&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="na"&gt;buttonType&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;full&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;
    &lt;span class="p"&gt;};&lt;/span&gt;
    &lt;span class="k"&gt;super&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;props&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="nx"&gt;render&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;handleButtonTypeSelection&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;changedButtonType&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;setState&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt; &lt;span class="na"&gt;buttonType&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;changedButtonType&lt;/span&gt; &lt;span class="p"&gt;});&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;
      &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;AppProvider&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
        ...
      &lt;span class="p"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nc"&gt;AppProvider&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="k"&gt;default&lt;/span&gt; &lt;span class="nx"&gt;App&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;This part:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;setState&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt; &lt;span class="na"&gt;buttonType&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;changedButtonType&lt;/span&gt; &lt;span class="p"&gt;});&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Changes the value of &lt;code&gt;buttonType&lt;/code&gt; in the state of the component. Specifically, what it's doing is passing a &lt;em&gt;destructured&lt;/em&gt; object into the &lt;code&gt;setState&lt;/code&gt; function (which, as you probably guessed, sets the state). &lt;a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Destructuring_assignment#Object_destructuring"&gt;Destructuring&lt;/a&gt; is a totally awesome (and rather new) concept in JavaScript, that basically allows you to unpack properties from objects, and treat them as simple variables. The statement above, therefore, is exactly like doing:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;newState&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="na"&gt;buttonType&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;changedButtonType&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;setState&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;newState&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;But the destructuring just saved me an unneccessary variable declaration. &lt;/p&gt;

&lt;p&gt;Back to business - we now have our callback function, but still missing our &lt;code&gt;RadioButton&lt;/code&gt; components. Let's finally put them in, and get the following:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight jsx"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;React&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;react&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;Page&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;AppProvider&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;Layout&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;Card&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;RadioButton&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;@shopify/polaris&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;@shopify/polaris/styles.css&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nx"&gt;App&lt;/span&gt; &lt;span class="kd"&gt;extends&lt;/span&gt; &lt;span class="nx"&gt;React&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;Component&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;constructor&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;props&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;super&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;props&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;state&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="na"&gt;buttonType&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;empty&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="p"&gt;};&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;

  &lt;span class="nx"&gt;render&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;handleButtonTypeSelection&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;changedButtonType&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;setState&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt; &lt;span class="na"&gt;buttonType&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;changedButtonType&lt;/span&gt; &lt;span class="p"&gt;});&lt;/span&gt;
    &lt;span class="p"&gt;};&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;
      &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;AppProvider&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
        &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;Page&lt;/span&gt;
          &lt;span class="na"&gt;title&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"Welcome!"&lt;/span&gt;
          &lt;span class="na"&gt;subtitle&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"Please select the type of button you'd like to generate for your site:"&lt;/span&gt;
        &lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
          &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;Layout&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
            &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;Layout&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;Section&lt;/span&gt; &lt;span class="na"&gt;oneHalf&lt;/span&gt; &lt;span class="na"&gt;secondary&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
              &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;Card&lt;/span&gt; &lt;span class="na"&gt;title&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"Black Button Variant"&lt;/span&gt; &lt;span class="na"&gt;sectioned&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
                &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;Card&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;Section&lt;/span&gt; &lt;span class="na"&gt;title&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"Demo"&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
                  &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nt"&gt;button&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;Dummy Full Button&lt;span class="p"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nt"&gt;button&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
                &lt;span class="p"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nc"&gt;Card&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;Section&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
                &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;Card&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;Section&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
                  &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;RadioButton&lt;/span&gt;
                    &lt;span class="na"&gt;label&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"Choose Full Button"&lt;/span&gt;
                    &lt;span class="na"&gt;helpText&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"Works well with the default Shopify themes and lighter backgrounds."&lt;/span&gt;
                    &lt;span class="na"&gt;checked&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;state&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;buttonType&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;full&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;
                    &lt;span class="na"&gt;id&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"full"&lt;/span&gt;
                    &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"full-button"&lt;/span&gt;
                    &lt;span class="na"&gt;onChange&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nx"&gt;handleButtonTypeSelection&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;full&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;
                  &lt;span class="p"&gt;/&amp;gt;&lt;/span&gt;
                &lt;span class="p"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nc"&gt;Card&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;Section&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
              &lt;span class="p"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nc"&gt;Card&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
            &lt;span class="p"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nc"&gt;Layout&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;Section&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
            &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;Layout&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;Section&lt;/span&gt; &lt;span class="na"&gt;oneHalf&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
              &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;Card&lt;/span&gt; &lt;span class="na"&gt;title&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"Empty Button Variant"&lt;/span&gt; &lt;span class="na"&gt;sectioned&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
                &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;Card&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;Section&lt;/span&gt; &lt;span class="na"&gt;title&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"Demo"&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
                  &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nt"&gt;button&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;Dummy Empty Button&lt;span class="p"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nt"&gt;button&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
                &lt;span class="p"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nc"&gt;Card&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;Section&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
                &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;Card&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;Section&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
                  &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;RadioButton&lt;/span&gt;
                    &lt;span class="na"&gt;label&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"Choose Empty Button"&lt;/span&gt;
                    &lt;span class="na"&gt;helpText&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"Works well with darker backgrounds, to create a high-contrast feel."&lt;/span&gt;
                    &lt;span class="na"&gt;checked&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;state&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;buttonType&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;empty&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;
                    &lt;span class="na"&gt;id&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"empty"&lt;/span&gt;
                    &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"empty-button"&lt;/span&gt;
                    &lt;span class="na"&gt;onChange&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nx"&gt;handleButtonTypeSelection&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;empty&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;
                  &lt;span class="p"&gt;/&amp;gt;&lt;/span&gt;
                &lt;span class="p"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nc"&gt;Card&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;Section&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
              &lt;span class="p"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nc"&gt;Card&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
            &lt;span class="p"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nc"&gt;Layout&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;Section&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
          &lt;span class="p"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nc"&gt;Layout&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
        &lt;span class="p"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nc"&gt;Page&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
      &lt;span class="p"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nc"&gt;AppProvider&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="k"&gt;default&lt;/span&gt; &lt;span class="nx"&gt;App&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Which should render like so:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--CzrUkumA--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/ty52kmi4v8j8z3oicose.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--CzrUkumA--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/ty52kmi4v8j8z3oicose.png" alt="Radio Buttons"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Try checking and unchecking both &lt;code&gt;RadioButton&lt;/code&gt;s, and observe that only one of them can be checked at any given moment. This is due to each of them pulling its &lt;code&gt;checked&lt;/code&gt; prop from the value of the &lt;code&gt;buttonType&lt;/code&gt; state property.&lt;/p&gt;

&lt;p&gt;That's enough for today, I think. :) We covered a lot of not-strictly-related ground, but I think it was a good detour into JavaScript and the cool features it has to offer.&lt;/p&gt;

&lt;h4&gt;
  
  
  An Offer
&lt;/h4&gt;

&lt;p&gt;If you're working on a Shopify app, and your app uses Polaris for the front-end, I want to hear from you. I am willing to sit down and run a debug session / add a new feature with you for your application, if you agree to stream it live with me (or record it and publish it later). It's not easy writing a full-stack JS app, doubly so when you're not from within the ecosystem. Let's do it together and help all the people! :)&lt;/p&gt;

&lt;p&gt;E-Mail me at &lt;a href="//mailto:hey@redcaptom.com"&gt;hey@redcaptom.com&lt;/a&gt;, and let's set it up.&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>react</category>
      <category>shopify</category>
      <category>shopifyapps</category>
    </item>
    <item>
      <title>Shopify App From Scratch #11 - User Interface 1</title>
      <dc:creator>Red Cap Tom</dc:creator>
      <pubDate>Sat, 13 Jun 2020 08:48:34 +0000</pubDate>
      <link>https://forem.com/redcaptom/shopify-app-from-scratch-11-user-interface-1-47n4</link>
      <guid>https://forem.com/redcaptom/shopify-app-from-scratch-11-user-interface-1-47n4</guid>
      <description>&lt;h2&gt;
  
  
  Deprecation Notice
&lt;/h2&gt;

&lt;p&gt;Yeah, yeah, I know. I hate it too when people abandon tutorial series mid-way. But, due to (exciting!) circumstances, I'm calling it quits for now.&lt;/p&gt;

&lt;p&gt;I'm thinking of just dropping a link to the full repo here - it's a mess, but it's something you guys can chew on instead of my empty promises.&lt;/p&gt;

&lt;p&gt;If you'd like me to drop it here - let me know at &lt;a href="mailto:hey@redcaptom.com"&gt;hey@redcaptom.com&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;And, just sayin', I had a BLAST doing this. If you know something - anything - about technology, take the time to write it down as a tutorial series. You will get SO, SO much value out of it, you can't even believe it.&lt;/p&gt;

&lt;p&gt;Until we meet again - RCT :)&lt;/p&gt;

&lt;h2&gt;
  
  
  The Video (Scroll down for the article)
&lt;/h2&gt;

&lt;p&gt;Coming soon!&lt;/p&gt;

&lt;h2&gt;
  
  
  Building the User Interface
&lt;/h2&gt;

&lt;p&gt;Alright, we're finally here - it's time to get building!&lt;/p&gt;

&lt;p&gt;If you follow the official tutorials, the way Shopify teaches you how to build apps revolves around the backend first, and the frontend later. I take a different approach, mostly for the sake of speed of iteration (it's much faster to mock a backend in order to build a frontend, than it is to mock a frontend in order to build a backed IMHO). Another advantage is that you don't end up writing useless backend routes that never gets called - once the interface is all lined up, it's clear what needs building on the backend.&lt;/p&gt;

&lt;h3&gt;
  
  
  Getting ready
&lt;/h3&gt;

&lt;p&gt;From now on, every line of code will go into a Git repository, with every post in the series represented as a commit. This is to allow you to follow along as I do my thing, and so you can revert back (more on this later) if you get stuck somewhere along the way. &lt;/p&gt;

&lt;p&gt;Note that the link I post here is to the &lt;strong&gt;tree of the relevant commit&lt;/strong&gt;. This might sound complicated, but I'd like to assure you that it's not - it's a feature of Git exposed by Github. All that means from your perspective is that the &lt;em&gt;state&lt;/em&gt; of the repository in that link - i.e. the files you will see - match the state of the repository when I wrote this tutorial. Here is the &lt;a href="https://github.com/redcaptom/countries-we-ship-to-button/tree/20b97059275438191a8d7151ff5f126d5dae2826"&gt;state of the repository for this tutorial&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;If you need further explanation - please let me know!&lt;/p&gt;

&lt;h3&gt;
  
  
  a Note About the Terminal
&lt;/h3&gt;

&lt;p&gt;It's probably obvious by now that I'm not using Windows for these tutorials. I'd &lt;em&gt;really&lt;/em&gt; like to be able to contribute more to the Windows-folk out there (I assume you guys are the majority here), and if you recall I tried to give Windows alternatives when unix tools were unix-only (read: &lt;code&gt;nvm-windows&lt;/code&gt;). If at any point you're not sure which command is which in Windows, just email me at &lt;a href="//mailto:hey@recaptom.com"&gt;hey@redcaptom.com&lt;/a&gt; and I'll edit the information in.&lt;/p&gt;

&lt;p&gt;Recall our previous mockup:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--lnEH74lK--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/ide5vtx1olpmln6ekvu6.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--lnEH74lK--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/ide5vtx1olpmln6ekvu6.png" alt="Mockup"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;We will now attempt to recreate it in React and Shopify Polaris. Let's first get the correct node version (we'll use the LTS version which is 12.18.0 at the time of writing - this version will be supported for a long while from now). For that we'll need &lt;a href="https://github.com/nvm-sh/nvm"&gt;&lt;code&gt;nvm&lt;/code&gt;&lt;/a&gt;, which you can get from &lt;a href="https://github.com/nvm-sh/nvm#installing-and-updating"&gt;here&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;This makes sure we will have the correct version added to source control, allowing anyone who uses the project to use the same Node.js version that we do.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight shell"&gt;&lt;code&gt;nvm &lt;span class="nb"&gt;install &lt;/span&gt;12.18.0 &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="se"&gt;\&lt;/span&gt;
nvm use 12.18.0
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;From here on we have two options: We either roll our own project scaffolding, or we use a scaffolding tool to do the work for us. Remember - this is &lt;em&gt;not&lt;/em&gt; the final version of our app, which will use &lt;a href="https://nextjs.org/learn/"&gt;Next.js&lt;/a&gt; as the main backbone. This is just an experimentation playground - one step removed from all the complexity - where we can build our React &amp;amp; Polaris interface in an isolated way, away from the full app.&lt;/p&gt;

&lt;p&gt;For that purpose, then, we will use &lt;code&gt;create-react-app&lt;/code&gt; that we've seen in the React sidestep, add Polaris to it and voila - we're good to go!&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;cd&lt;/span&gt; ~ &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="se"&gt;\&lt;/span&gt;
npx create-react-app countries-we-ship-to-button &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="se"&gt;\&lt;/span&gt;
countries-we-ship-to-button
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Wait for that bad boy to finish, and you will find yourself inside the project folder.&lt;/p&gt;

&lt;p&gt;In order to begin work on the interface, we're going to need Shopify Polaris:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight shell"&gt;&lt;code&gt;npm &lt;span class="nb"&gt;install&lt;/span&gt; @shopify/polaris
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Ignore any warnings that come by - we're using a very mainstream package with great support. If something does not work out of the box in this stage - it's probably not the package's fault.&lt;/p&gt;

&lt;p&gt;By the way - that &lt;code&gt;@&lt;/code&gt; there, in &lt;code&gt;@shopify/polaris&lt;/code&gt;? That's called a &lt;a href="https://stackoverflow.com/a/36667439"&gt;"Scoped NPM Package"&lt;/a&gt;, and it means that this is an official module from Shopify. Goodie! :)&lt;/p&gt;

&lt;h3&gt;
  
  
  Starting For Real Now
&lt;/h3&gt;

&lt;p&gt;Let's dive in! The scaffolding that &lt;code&gt;create-react-app&lt;/code&gt; does allows us to use &lt;code&gt;App.js&lt;/code&gt; for experimentation - everything is loaded up and ready to go. Your &lt;code&gt;App.js&lt;/code&gt; should look like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight jsx"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;React&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;react&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;logo&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;./logo.svg&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;./App.css&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nx"&gt;App&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nt"&gt;div&lt;/span&gt; &lt;span class="na"&gt;className&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"App"&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
      &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nt"&gt;header&lt;/span&gt; &lt;span class="na"&gt;className&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"App-header"&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
        &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nt"&gt;img&lt;/span&gt; &lt;span class="na"&gt;src&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;logo&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt; &lt;span class="na"&gt;className&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"App-logo"&lt;/span&gt; &lt;span class="na"&gt;alt&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"logo"&lt;/span&gt; &lt;span class="p"&gt;/&amp;gt;&lt;/span&gt;
        &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nt"&gt;p&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
          Edit &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nt"&gt;code&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;src/App.js&lt;span class="p"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nt"&gt;code&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt; and save to reload.
        &lt;span class="p"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nt"&gt;p&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
        &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nt"&gt;a&lt;/span&gt;
          &lt;span class="na"&gt;className&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"App-link"&lt;/span&gt;
          &lt;span class="na"&gt;href&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"https://reactjs.org"&lt;/span&gt;
          &lt;span class="na"&gt;target&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"_blank"&lt;/span&gt;
          &lt;span class="na"&gt;rel&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"noopener noreferrer"&lt;/span&gt;
        &lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
          Learn React
        &lt;span class="p"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nt"&gt;a&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
      &lt;span class="p"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nt"&gt;header&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="p"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nt"&gt;div&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
  &lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="k"&gt;default&lt;/span&gt; &lt;span class="nx"&gt;App&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;And we can get going. Let's first turn the functional component into a class component, since this component is going to be rather large, and I prefer to have my larger components as classes and my smaller ones as functional components:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight jsx"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;React&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;react&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nx"&gt;App&lt;/span&gt; &lt;span class="kd"&gt;extends&lt;/span&gt; &lt;span class="nx"&gt;React&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;Component&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nx"&gt;render&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;

    &lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="k"&gt;default&lt;/span&gt; &lt;span class="nx"&gt;App&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;We can now import Polaris (note how we're importing both the library and they style files - this is just because we're playing with the interface here manually, and will be abstracted away once we move over to Next.js), and specifically the &lt;code&gt;&amp;lt;Page&amp;gt;&lt;/code&gt; component, which will be the first Polaris component we use:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight jsx"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;React&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;react&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;Page&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;@shopify/polaris&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;@shopify/polaris/styles.css&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nx"&gt;App&lt;/span&gt; &lt;span class="kd"&gt;extends&lt;/span&gt; &lt;span class="nx"&gt;React&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;Component&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nx"&gt;render&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;
      &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;Polaris&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;Page&lt;/span&gt;
        &lt;span class="na"&gt;title&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"Welcome!"&lt;/span&gt;
        &lt;span class="na"&gt;subtitle&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"Please select the type of button you'd like to generate for your site:"&lt;/span&gt;
      &lt;span class="p"&gt;&amp;gt;&amp;lt;/&lt;/span&gt;&lt;span class="nc"&gt;Polaris&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;Page&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="k"&gt;default&lt;/span&gt; &lt;span class="nx"&gt;App&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Let's run our code, to see how it looks like live! Type the following into your terminal:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight shell"&gt;&lt;code&gt;npm start
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;And you should see the following error message:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--z2O6_Y-2--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/secjvek6o2dgdrz4lhkg.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--z2O6_Y-2--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/secjvek6o2dgdrz4lhkg.png" alt="Oh No, Error!"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This is perfectly fine, and has to do with how Shopify apps are expected to be built. Shopify has a special component called &lt;a href="https://polaris.shopify.com/components/structure/app-provider"&gt;AppProvider&lt;/a&gt; that wraps all Shopify apps, allowing all the components in the app to share a set of properties across the board. Don't fuss too much about it right now - we'll deal with it later. For now, just add it to your code to make sure you pass the check:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight jsx"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;React&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;react&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;Page&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;AppProvider&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;@shopify/polaris&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;@shopify/polaris/styles.css&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nx"&gt;App&lt;/span&gt; &lt;span class="kd"&gt;extends&lt;/span&gt; &lt;span class="nx"&gt;React&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;Component&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nx"&gt;render&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;
      &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;AppProvider&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
        &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;Page&lt;/span&gt;
          &lt;span class="na"&gt;title&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"Welcome!"&lt;/span&gt;
          &lt;span class="na"&gt;subtitle&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"Please select the type of button you'd like to generate for your site:"&lt;/span&gt;
        &lt;span class="p"&gt;&amp;gt;&amp;lt;/&lt;/span&gt;&lt;span class="nc"&gt;Page&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
      &lt;span class="p"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nc"&gt;AppProvider&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="k"&gt;default&lt;/span&gt; &lt;span class="nx"&gt;App&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;You should now see the following:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--soCKg1ad--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/y9xdlfco77r1xkiqnos5.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--soCKg1ad--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/y9xdlfco77r1xkiqnos5.png" alt="Shaping Up"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Which means that Polaris is properly installed, and we have created our first page!&lt;/p&gt;

&lt;p&gt;We'd like to now create a proper layout for our page. Fortunately, Polaris provides the &lt;a href="https://polaris.shopify.com/components/structure/layout"&gt;Layout&lt;/a&gt; component to let us scaffold the page properly. Let's add it now to create two half-sections for our page, just like in the schema we drew up before:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight jsx"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;React&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;react&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;Page&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;AppProvider&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;Layout&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;@shopify/polaris&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;@shopify/polaris/styles.css&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nx"&gt;App&lt;/span&gt; &lt;span class="kd"&gt;extends&lt;/span&gt; &lt;span class="nx"&gt;React&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;Component&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nx"&gt;render&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;
      &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;AppProvider&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
        &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;Page&lt;/span&gt;
          &lt;span class="na"&gt;title&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"Welcome!"&lt;/span&gt;
          &lt;span class="na"&gt;subtitle&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"Please select the type of button you'd like to generate for your site:"&lt;/span&gt;
        &lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
          &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;Layout&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
            &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;Layout&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;Section&lt;/span&gt; &lt;span class="na"&gt;oneHalf&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
              &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nt"&gt;h1&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;First Half&lt;span class="p"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nt"&gt;h1&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
            &lt;span class="p"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nc"&gt;Layout&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;Section&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
            &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;Layout&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;Section&lt;/span&gt; &lt;span class="na"&gt;oneHalf&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
              &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nt"&gt;h1&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;Second Half&lt;span class="p"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nt"&gt;h1&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
            &lt;span class="p"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nc"&gt;Layout&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;Section&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
          &lt;span class="p"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nc"&gt;Layout&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
        &lt;span class="p"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nc"&gt;Page&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
      &lt;span class="p"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nc"&gt;AppProvider&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="k"&gt;default&lt;/span&gt; &lt;span class="nx"&gt;App&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;You should now see something like this:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--1Mf2RQnc--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/p0ssvmud32ny4ak2qlme.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--1Mf2RQnc--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/p0ssvmud32ny4ak2qlme.png" alt="Half &amp;amp; Half"&gt;&lt;/a&gt;&lt;br&gt;
Note that the &lt;code&gt;Layout&lt;/code&gt; component has a sub-component called &lt;code&gt;Section&lt;/code&gt;. This is what the &lt;code&gt;Layout.Section&lt;/code&gt; syntax means - it's a component within a component. Specifically, since a component is actually a function, &lt;code&gt;Section&lt;/code&gt; is a property of that function, that just happens to be another function. An in React-speak, this is a component &lt;em&gt;nested&lt;/em&gt; inside another component.&lt;/p&gt;

&lt;p&gt;Note also the &lt;code&gt;oneHalf&lt;/code&gt; property (i.e. 'prop') we gave the &lt;code&gt;Layout.Section&lt;/code&gt; component - this is one variant out of a few (see &lt;a href="https://github.com/Shopify/polaris-react/blob/master/src/components/Layout/components/Section/Section.tsx#L8-L11"&gt;here&lt;/a&gt;) that we can give the section to form a "grid" of sorts on the page. This is useful if you'd like to have columns in your page (created by multiple &lt;code&gt;Section&lt;/code&gt;s in the same &lt;code&gt;Layout&lt;/code&gt;, each with a &lt;code&gt;oneHalf&lt;/code&gt; or &lt;code&gt;oneThird&lt;/code&gt; property supplied to it).&lt;/p&gt;

&lt;p&gt;But this is still not a great look, since the headers are kind of "floating" in the page. Let's wrap them in a &lt;a href="https://polaris.shopify.com/components/structure/card"&gt;Card&lt;/a&gt; component, shall we?&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight jsx"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;React&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;react&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;Page&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;AppProvider&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;Layout&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;Card&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;@shopify/polaris&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;@shopify/polaris/styles.css&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nx"&gt;App&lt;/span&gt; &lt;span class="kd"&gt;extends&lt;/span&gt; &lt;span class="nx"&gt;React&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;Component&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nx"&gt;render&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;
      &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;AppProvider&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
        &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;Page&lt;/span&gt;
          &lt;span class="na"&gt;title&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"Welcome!"&lt;/span&gt;
          &lt;span class="na"&gt;subtitle&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"Please select the type of button you'd like to generate for your site:"&lt;/span&gt;
        &lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
          &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;Layout&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
            &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;Layout&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;Section&lt;/span&gt; &lt;span class="na"&gt;oneHalf&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
              &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;Card&lt;/span&gt; &lt;span class="na"&gt;title&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"First Half"&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&amp;lt;/&lt;/span&gt;&lt;span class="nc"&gt;Card&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
            &lt;span class="p"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nc"&gt;Layout&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;Section&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
            &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;Layout&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;Section&lt;/span&gt; &lt;span class="na"&gt;oneHalf&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
              &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;Card&lt;/span&gt; &lt;span class="na"&gt;title&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"Second Half"&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&amp;lt;/&lt;/span&gt;&lt;span class="nc"&gt;Card&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
            &lt;span class="p"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nc"&gt;Layout&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;Section&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
          &lt;span class="p"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nc"&gt;Layout&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
        &lt;span class="p"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nc"&gt;Page&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
      &lt;span class="p"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nc"&gt;AppProvider&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="k"&gt;default&lt;/span&gt; &lt;span class="nx"&gt;App&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;It should now look like this:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--axoE3BKS--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/y5xapeca0bct8l3z2g63.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--axoE3BKS--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/y5xapeca0bct8l3z2g63.png" alt="Oooooh Cards"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Let's add some content into our cards, by sectioning it out - this will later act as a menu from which the customer can choose which type of button they'd like to have in their website. That way, the &lt;em&gt;content&lt;/em&gt; of each selection will be a demo of one variant of the button (we will actually implement that button later, so I'll use a dummy one for now). Note that this is similar in nature to &lt;code&gt;Section&lt;/code&gt;ing out the &lt;code&gt;Layout&lt;/code&gt; interface like we did before:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight jsx"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;React&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;react&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;Page&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;AppProvider&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;Layout&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;Card&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;@shopify/polaris&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;@shopify/polaris/styles.css&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nx"&gt;App&lt;/span&gt; &lt;span class="kd"&gt;extends&lt;/span&gt; &lt;span class="nx"&gt;React&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;Component&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nx"&gt;render&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;
      &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;AppProvider&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
        &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;Page&lt;/span&gt;
          &lt;span class="na"&gt;title&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"Welcome!"&lt;/span&gt;
          &lt;span class="na"&gt;subtitle&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"Please select the type of button you'd like to generate for your site:"&lt;/span&gt;
        &lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
          &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;Layout&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
            &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;Layout&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;Section&lt;/span&gt; &lt;span class="na"&gt;oneHalf&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
              &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;Card&lt;/span&gt; &lt;span class="na"&gt;title&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"Full Button Variant"&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
                &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;Card&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;Section&lt;/span&gt; &lt;span class="na"&gt;title&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"Demo"&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
                  &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nt"&gt;button&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;Dummy Full Button&lt;span class="p"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nt"&gt;button&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
                &lt;span class="p"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nc"&gt;Card&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;Section&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
              &lt;span class="p"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nc"&gt;Card&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
            &lt;span class="p"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nc"&gt;Layout&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;Section&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
            &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;Layout&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;Section&lt;/span&gt; &lt;span class="na"&gt;oneHalf&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
              &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;Card&lt;/span&gt; &lt;span class="na"&gt;title&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"Empty Button Variant"&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
                &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;Card&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;Section&lt;/span&gt; &lt;span class="na"&gt;title&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"Demo"&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
                  &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nt"&gt;button&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;Dummy Empty Button&lt;span class="p"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nt"&gt;button&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
                &lt;span class="p"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nc"&gt;Card&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;Section&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
              &lt;span class="p"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nc"&gt;Card&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
            &lt;span class="p"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nc"&gt;Layout&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;Section&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
          &lt;span class="p"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nc"&gt;Layout&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
        &lt;span class="p"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nc"&gt;Page&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
      &lt;span class="p"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nc"&gt;AppProvider&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="k"&gt;default&lt;/span&gt; &lt;span class="nx"&gt;App&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--lfFuETB7--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/wqeu5e75bzac8z7p19n7.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--lfFuETB7--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/wqeu5e75bzac8z7p19n7.png" alt="Boo-Yah!"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;And I think this is enough for this post. We now have a working playground to play with, as well as a start to our product page! Stay tuned for the rest of the interface in the upcoming tutorials.&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>react</category>
      <category>shopify</category>
      <category>shopifyapps</category>
    </item>
    <item>
      <title>Shopify App From Scratch #10 - Shopify Polaris</title>
      <dc:creator>Red Cap Tom</dc:creator>
      <pubDate>Sat, 06 Jun 2020 17:32:37 +0000</pubDate>
      <link>https://forem.com/redcaptom/shopify-app-from-scratch-10-shopify-polaris-57co</link>
      <guid>https://forem.com/redcaptom/shopify-app-from-scratch-10-shopify-polaris-57co</guid>
      <description>&lt;h2&gt;
  
  
  Deprecation Notice
&lt;/h2&gt;

&lt;p&gt;Yeah, yeah, I know. I hate it too when people abandon tutorial series mid-way. But, due to (exciting!) circumstances, I'm calling it quits for now.&lt;/p&gt;

&lt;p&gt;I'm thinking of just dropping a link to the full repo here - it's a mess, but it's something you guys can chew on instead of my empty promises.&lt;/p&gt;

&lt;p&gt;If you'd like me to drop it here - let me know at &lt;a href="mailto:hey@redcaptom.com"&gt;hey@redcaptom.com&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;And, just sayin', I had a BLAST doing this. If you know something - anything - about technology, take the time to write it down as a tutorial series. You will get SO, SO much value out of it, you can't even believe it.&lt;/p&gt;

&lt;p&gt;Until we meet again - RCT :)&lt;/p&gt;

&lt;h2&gt;
  
  
  The Video (Scroll down for the article)
&lt;/h2&gt;

&lt;p&gt;Coming soon!&lt;/p&gt;

&lt;h3&gt;
  
  
  Introduction
&lt;/h3&gt;

&lt;p&gt;When you're building a large collection of independent components across a large enough team, people are going to have opinions about how to design each part of the system. This, in and of itself, is not a bad thing - product managers, engineers and designers should all pitch in on the look and feel of the system to provide a holistic perspective of what's desired, what's possible and what's most awesome-looking. But there are some thing that should remain consistent across the entire stack - the colors of buttons, the fonts, the look and feel of tables, the general padding and margin and borders of elements, etc.&lt;/p&gt;

&lt;p&gt;A while back, there was no proper name for this desired "universalism" across the front-end part of software projects. At some point, most likely around the arrival of component-based frameworks (read: React), it became apparent to some of the largest software players in the world that having a universal design language for their products is probably a good idea. Some examples include Google's &lt;a href="https://material.io/design" rel="noopener noreferrer"&gt;Material Design&lt;/a&gt;, GitHub's &lt;a href="https://primer.style/" rel="noopener noreferrer"&gt;Primer&lt;/a&gt; and MailChimp's &lt;a href="https://ux.mailchimp.com/patterns/color" rel="noopener noreferrer"&gt;Patterns&lt;/a&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  What's in a design system?
&lt;/h3&gt;

&lt;p&gt;Most modern design system consist of multiple components, which can be divided roughly into two parts:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Visual Guidelines - Instructions on what colors, typography, language, spacing etc. to use in the software.&lt;/li&gt;
&lt;li&gt;Components - A set of often-used components that embody those visual guidelines, written in a widely used framework (React is a often a prime candidate, but you might see Vue.js or plain HTML components as well).&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;In the video I focus a bit more on the visual guidelines, but in this post I'll deal mostly with the components.&lt;/p&gt;

&lt;h3&gt;
  
  
  Why should you care?
&lt;/h3&gt;

&lt;p&gt;Generally speaking, if you're building a software product as part of another software company's ecosystem, and your product is intended to complement said company's product - you'll do well to comply with their design system. It will cause your product to integrate into the platform better, will save you the trouble of making a lot of design decisions and will often also save you quite a bit of time.&lt;/p&gt;

&lt;p&gt;This goes double for products that are directly &lt;strong&gt;embedded&lt;/strong&gt; into another piece of software - like Shopify apps. There are a lot of apps out there that use their own styles (usually &lt;a href="https://getbootstrap.com/" rel="noopener noreferrer"&gt;Bootstrap&lt;/a&gt;) which just looks.... bad.&lt;/p&gt;

&lt;p&gt;If you're building something to delight your users, and you're part of a larger ecosystem - you should either conform (if the outer styles are good) or differentiate (if the outer styles are the worst). In this case, Shopify really made a good design move, and I'd offer you to conform to their standards (and, to be honest, it does not hurt your chances of getting your app approved).&lt;/p&gt;

&lt;h3&gt;
  
  
  Shopify Polaris - Shopify's Own Design System
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://polaris.shopify.com/" rel="noopener noreferrer"&gt;Polaris&lt;/a&gt; is Shopify's own foray into the design system game, and I will focus specifically on &lt;a href="https://github.com/Shopify/polaris-react" rel="noopener noreferrer"&gt;&lt;code&gt;polaris-react&lt;/code&gt; &lt;/a&gt; - the React-based, Polaris-compliant component set.&lt;/p&gt;

&lt;p&gt;First and foremost, it's important to note that the components we're going to see here look a little differently than the ones we've seen before. This is because they are not written in simple JavaScript, but in a superset of JavaScript called Typescript. What is a superset, you may ask? It's a set, that contains another set, and then some. What, you may rightfully ask, are you talking about? Doesn't matter. For the sake of this discussion, TypeScript is Javascript - &lt;strong&gt;with types&lt;/strong&gt;. Fun to be had by all!&lt;/p&gt;

&lt;p&gt;Seriously though, the only reason I'm even mentioning this is because I want you to understand that Polaris is not really anything new - it's just a bunch of components neatly wrapped up in a package. You should be able to re-create them yourself if you so please, not to mention be able to understand them. However, like in the case with React, I think it serves us to observe what they look like in the wild. To that end, I will take a look at two different components, one simple and one a bit more complicated and got a bit into depth on how they're built and how to use them.&lt;/p&gt;

&lt;h3&gt;
  
  
  Example Component - Button
&lt;/h3&gt;

&lt;p&gt;The "Hello World" of Polaris is, in my opinion, the button:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Polaris Docs - &lt;a href="https://polaris.shopify.com/components/actions/button" rel="noopener noreferrer"&gt;Button&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;GitHub Repo - &lt;a href="https://github.com/Shopify/polaris-react/tree/master/src/components/Button" rel="noopener noreferrer"&gt;Button&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Consider the directory structure of that button (located at &lt;code&gt;https://github.com/Shopify/polaris-react/tree/master/src/components/Button&lt;/code&gt; ):&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight markdown"&gt;&lt;code&gt;&lt;span class="gh"&gt;# Button&lt;/span&gt;
&lt;span class="p"&gt;
*&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nv"&gt;tests/&lt;/span&gt;&lt;span class="p"&gt;](&lt;/span&gt;&lt;span class="sx"&gt;./Button/tests&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;  +&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nv"&gt;Button.test.tsx&lt;/span&gt;&lt;span class="p"&gt;](&lt;/span&gt;&lt;span class="sx"&gt;./Button/tests/Button.test.tsx&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;*&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nv"&gt;Button.scss&lt;/span&gt;&lt;span class="p"&gt;](&lt;/span&gt;&lt;span class="sx"&gt;./Button/Button.scss&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;*&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nv"&gt;Button.tsx&lt;/span&gt;&lt;span class="p"&gt;](&lt;/span&gt;&lt;span class="sx"&gt;./Button/Button.tsx&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;*&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nv"&gt;README.md&lt;/span&gt;&lt;span class="p"&gt;](&lt;/span&gt;&lt;span class="sx"&gt;./Button/README.md&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;*&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nv"&gt;index.ts&lt;/span&gt;&lt;span class="p"&gt;](&lt;/span&gt;&lt;span class="sx"&gt;./Button/index.ts&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;*&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nv"&gt;utils.tsx&lt;/span&gt;&lt;span class="p"&gt;](&lt;/span&gt;&lt;span class="sx"&gt;./Button/utils.tsx&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

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

&lt;/div&gt;



&lt;p&gt;This feels like a lot of stuff for a button, right? Let's break it down:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;tests&lt;/code&gt; - React components are, by definition, individual units of code that structure an application's UI. They are the atomic bits of your user interface, and by popular opinion should be tested individually before being combined together. It's therefore common to create tests for each component separately, and then bundle those tests in proximity to the component. This allows users to pick-and-choose the components they like, and still have unit tests available for the taking immediately. These tests are written (in Polaris's case) using a testing framework for JavaScript called &lt;a href="https://mochajs.org/" rel="noopener noreferrer"&gt;Mocha&lt;/a&gt;, originally written by the ever-awesome &lt;a href="https://github.com/tj" rel="noopener noreferrer"&gt;TJ Holowaychuk&lt;/a&gt;. If you're reading this, dear TJ - we love you here in JS land. You the bomb.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;Button.scss&lt;/code&gt; - There a few different ways of styling React components, and in this specific case the Shopify staff chose to use a preprocessor (&lt;a href="https://sass-lang.com/" rel="noopener noreferrer"&gt;Sass&lt;/a&gt;). Sass is similar to CSS in some ways, and is looked at as a CSS "extension language" - you have a bit more flexibility in defining your styles, and they take care of translating the Sass syntax into proper CSS. Since we will not be using Sass, I will not say anything further about it (I will mention, however, that it is one of those things I have very little knowledge about but always wanted to dive into deeper).&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;Button.tsx&lt;/code&gt; - The TypeScript-React file is actually a combination of two types of files - &lt;code&gt;.tsx&lt;/code&gt; stands for TypeScript ( &lt;code&gt;ts&lt;/code&gt; ) - with the possibility to embed JSX - ( &lt;code&gt;x&lt;/code&gt; ). Recall that JSX is what I referred to as "HTML On Steroids" - it's what your functional components return, that end up constructing the virtual DOM. If you take a deep dive inside, you'll see that it's quite a long file (350+ lines at the time of writing), which sounds a little bit surprising given that it's just a button. But, if you look closely at the Polaris docs, you'll see that this innocent button actually has 17 different possible configurations - all accessible by adding various in-tag attributes (i.e. React props) to the button:&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fpwiu4aq2dnnoqp4sdlna.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fpwiu4aq2dnnoqp4sdlna.png" alt="pic1"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;That's where &lt;code&gt;Button.tsx&lt;/code&gt; comes in - it's all about the props that you pass into the button, whose mixture configures how the button will look like.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;README.md&lt;/code&gt; - Just a README file.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;index.tx&lt;/code&gt; - This is just an export file - it ensures everything inside this folder is accessible to files from the outside. Unless you're super into the way JS projects need to be structured due to.... reasons, then this is just a detail and nothing else.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;utils.tsx&lt;/code&gt; - This file contains functions that help use the Button component from elsewhere. You will see this in action in the next section.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;All of those files eventually make, for example, this:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;&amp;lt;Button primary&amp;gt;Save theme&amp;lt;/Button&amp;gt;&lt;/code&gt; &lt;/p&gt;

&lt;p&gt;Into this:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fwq82b3aa3i1p345whwxb.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fwq82b3aa3i1p345whwxb.png" alt="pic2"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Which is not that much, right? Well, that's until you see that very same component as part of another component, and then everything starts to make a little more sense.&lt;/p&gt;

&lt;h3&gt;
  
  
  Example Component - Callout Card
&lt;/h3&gt;

&lt;p&gt;The beauty of Polaris, and actually React in general, is the fact that most things are re-used in some form or another in other things. In a more formal manner, a &lt;em&gt;hybrid component&lt;/em&gt; is a component that's composed of other components - exposing only the top-most component for you to interact with.&lt;/p&gt;

&lt;p&gt;It makes little sense for you to re-implement a button each time you need one, and doubly so if you'd like for the buttons to remain consistent across all your components. The Callout Card is component that combines a button inside of it, but you don't actually need to write &lt;code&gt;&amp;lt;Button&amp;gt;&lt;/code&gt; anywhere yourself - the component takes care of this for you.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Polaris Docs - &lt;a href="https://polaris.shopify.com/components/structure/callout-card#navigation" rel="noopener noreferrer"&gt;Callout Card&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;GitHub Repo - &lt;a href="https://github.com/Shopify/polaris-react/tree/master/src/components/CalloutCard" rel="noopener noreferrer"&gt;Callout Card&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This is how it looks like:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fxfe1ktnd45yjx2o3yyfr.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fxfe1ktnd45yjx2o3yyfr.png" alt="pic3"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;See the button there? It's actually created in the &lt;a href="https://github.com/Shopify/polaris-react/blob/master/src/components/CalloutCard/CalloutCard.tsx#L38" rel="noopener noreferrer"&gt;CalloutCard.tsx file&lt;/a&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight jsx"&gt;&lt;code&gt;  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;primaryActionMarkup&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;buttonFrom&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;primaryAction&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And remember the &lt;code&gt;utils.tsx&lt;/code&gt; file from the Button component? It actually contains this &lt;a href="https://github.com/Shopify/polaris-react/blob/master/src/components/Button/utils.tsx#L27-L37" rel="noopener noreferrer"&gt; &lt;code&gt;buttonFrom(action)&lt;/code&gt; &lt;/a&gt; funtion:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight jsx"&gt;&lt;code&gt;&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;buttonFrom&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
  &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;content&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;onAction&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;...&lt;/span&gt;&lt;span class="nx"&gt;action&lt;/span&gt;&lt;span class="p"&gt;}:&lt;/span&gt; &lt;span class="nx"&gt;ComplexAction&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nx"&gt;overrides&lt;/span&gt;&lt;span class="p"&gt;?:&lt;/span&gt; &lt;span class="nx"&gt;Partial&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;ButtonProps&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nx"&gt;key&lt;/span&gt;&lt;span class="p"&gt;?:&lt;/span&gt; &lt;span class="nx"&gt;any&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;return &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;Button&lt;/span&gt; &lt;span class="na"&gt;key&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;key&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt; &lt;span class="na"&gt;onClick&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;onAction&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt; &lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="p"&gt;...&lt;/span&gt;&lt;span class="nx"&gt;action&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt; &lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="p"&gt;...&lt;/span&gt;&lt;span class="nx"&gt;overrides&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
      &lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;content&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;
    &lt;span class="p"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nc"&gt;Button&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
  &lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;That, unsurprisingly, creates a button out of some &lt;code&gt;action&lt;/code&gt; , which is an abstraction of whatever it is you'd like the button to do - throw up a pop-up, call some long-running task, delete something, refresh the page etc.&lt;/p&gt;

&lt;p&gt;Let's look at the code for the CalloutCard this time, and actually observe how we can customize it. This is how the default CalloutCard looks like when you want to use it on your front-end:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight jsx"&gt;&lt;code&gt;&lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;CalloutCard&lt;/span&gt;
  &lt;span class="na"&gt;title&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"An Awesome TItle"&lt;/span&gt;
  &lt;span class="na"&gt;illustration&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"Some_Illustation_From_Undraw.svg"&lt;/span&gt;
  &lt;span class="na"&gt;primaryAction&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="na"&gt;content&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Button Text&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="na"&gt;url&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;http://SomeLink.com&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
  &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nt"&gt;p&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;Your Awesome Callout Card Text&lt;span class="p"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nt"&gt;p&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
&lt;span class="p"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nc"&gt;CalloutCard&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;So you are able to customize the following options of the card:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;title&lt;/code&gt; - The main piece of text the card promotes.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;illustration&lt;/code&gt; - Some illustration to be placed &lt;em&gt;in a strategice location&lt;/em&gt; in the button (see how that strategic placement is abstracted away from you? This is not a mistakle, but good design by the Shopify people). BTW, &lt;a href="https://undraw.co/illustrations" rel="noopener noreferrer"&gt;unDraw&lt;/a&gt; is this awesome project by the very talented &lt;a href="https://twitter.com/ninaLimpi" rel="noopener noreferrer"&gt;Katerina Limpitsouni&lt;/a&gt;, that aims to provide programmers with great, royalty-free and actually-free illustrations. You will see that I try to use it whenever I can in my projects, since her illustrations resemble Shopify ones visually, and have the same color scheme.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;primaryAction&lt;/code&gt; - An object to define what the button is there to "Call Out" for you to do:

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;content&lt;/code&gt; - The call to action, i.e. the text of the button.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;url&lt;/code&gt; - The URL to access when the button is pressed. This doesn't actually have to be a URL, and can be swapped for &lt;code&gt;action&lt;/code&gt; to perform some in-app operation (like calling a function).&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;/ul&gt;

&lt;p&gt;I think that's enough for Polaris - there's so much to go into, and I hope in the future to do a "Quick Hits" type series, talking and giving actual working examples of every Polaris component in production. For now, though, that should be enough to give you a feel for Polaris. Moving on!&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>react</category>
      <category>shopify</category>
      <category>shopifyapps</category>
    </item>
    <item>
      <title>Shopify App From Scratch #9 - React Sidestep 3</title>
      <dc:creator>Red Cap Tom</dc:creator>
      <pubDate>Sat, 06 Jun 2020 17:10:55 +0000</pubDate>
      <link>https://forem.com/redcaptom/shopify-app-from-scratch-9-react-sidestep-3-5g7g</link>
      <guid>https://forem.com/redcaptom/shopify-app-from-scratch-9-react-sidestep-3-5g7g</guid>
      <description>&lt;h2&gt;
  
  
  Deprecation Notice
&lt;/h2&gt;

&lt;p&gt;Yeah, yeah, I know. I hate it too when people abandon tutorial series mid-way. But, due to (exciting!) circumstances, I'm calling it quits for now.&lt;/p&gt;

&lt;p&gt;I'm thinking of just dropping a link to the full repo here - it's a mess, but it's something you guys can chew on instead of my empty promises.&lt;/p&gt;

&lt;p&gt;If you'd like me to drop it here - let me know at &lt;a href="mailto:hey@redcaptom.com"&gt;hey@redcaptom.com&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;And, just sayin', I had a BLAST doing this. If you know something - anything - about technology, take the time to write it down as a tutorial series. You will get SO, SO much value out of it, you can't even believe it.&lt;/p&gt;

&lt;p&gt;Until we meet again - RCT :)&lt;/p&gt;

&lt;h2&gt;
  
  
  The Video (Scroll down for the article)
&lt;/h2&gt;

&lt;p&gt;Coming soon!&lt;/p&gt;

&lt;h2&gt;
  
  
  React class components
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Introduction
&lt;/h3&gt;

&lt;p&gt;Generally speaking, you can get along in most simple React applications by just using functional components. If you need to keep some data that changes over the runtime of the application, for example, you can use the &lt;a href="https://reactjs.org/docs/hooks-state.html"&gt;&lt;code&gt;useState&lt;/code&gt; hook&lt;/a&gt;. If you need to do something when a component was added, removed or updated from the application then you can use the &lt;a href="https://reactjs.org/docs/hooks-effect.html"&gt;&lt;code&gt;useEffect&lt;/code&gt; hook&lt;/a&gt;. &lt;/p&gt;

&lt;p&gt;But, before React 16.8 (&lt;a href="https://en.wikipedia.org/wiki/React_(web_framework)#History"&gt;which was released in February 2019&lt;/a&gt;), hooks were not even a thing. They became available only after that release, meaning that &lt;em&gt;before&lt;/em&gt; February 2019 you could not have state in a functional component, or know that it has mounted or unmounted. In practice, you used functional components for the "simple" stuff, and class components for the "complicated" stuff.&lt;/p&gt;

&lt;p&gt;This is obviously no longer the case, but I still enjoy thinking in those terms. It offers perspective on what tools are correct for each job, and prevent you from over-complicating things with class components when you can just functionalize (is that a word?) your way to glory.&lt;/p&gt;

&lt;h3&gt;
  
  
  Class Components Are Heavyweights
&lt;/h3&gt;

&lt;p&gt;Class components are, from my perspective, a more heavyset version of functional components. They offer more fine-grained control over the component and are great as wrappers of functional components, but come at the price of more verbosity, a higher learning curve and less syntactic sugar than functional components. Let's take a look, shall we?&lt;/p&gt;

&lt;h3&gt;
  
  
  A note about classes in JavaScript
&lt;/h3&gt;

&lt;p&gt;I have to add  quick note on what a class actually is in JavaScript land: it's just a wrapper around existing JavaScript ideas, presented in a way that will appeal to Object-Oriented programmers. Put plainly - &lt;a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Classes"&gt;JS Classes&lt;/a&gt; are a way to define what a thing is, and then create occurrences of that thing in your application.&lt;/p&gt;

&lt;p&gt;This means that you can define that class once, and then use it (the correct term is "instantiate" it) anywhere else in your application. In practice, we do not do that &lt;em&gt;directly&lt;/em&gt; in React - you do not instantiate the class component you create: React does that for you when it mounts the component. You can re-use the component in many places in your application, sure, but you can also do that with functional components, right?&lt;/p&gt;

&lt;p&gt;This is confusing, and actually not very relevant if all you're trying to get is a grip on how React &lt;em&gt;looks like&lt;/em&gt; so you can pick up its ideas as you go along. For the sake of our discussion, then, I'm going to drop all reference to the &lt;em&gt;JS concept of a class&lt;/em&gt;, and focus instead on &lt;em&gt;React class components&lt;/em&gt; only. If you're still interested, &lt;a href="https://reactjs.org/docs/react-component.html"&gt;dive into the docs&lt;/a&gt; - they're really good.&lt;/p&gt;

&lt;h2&gt;
  
  
  How Does One Identify A React Class Component In The Wild?
&lt;/h2&gt;

&lt;h3&gt;
  
  
  The General Structure
&lt;/h3&gt;

&lt;p&gt;Excellent question. I'm going to take an &lt;a href="https://reactjs.org/docs/state-and-lifecycle.html"&gt;example from the official React docs&lt;/a&gt; and explain a little bit more on each part then they do there (although, if you come from an Object-Oriented background, you probably already know most of what I'll talk about):&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight jsx"&gt;&lt;code&gt;&lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nx"&gt;Clock&lt;/span&gt; &lt;span class="kd"&gt;extends&lt;/span&gt; &lt;span class="nx"&gt;React&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;Component&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;constructor&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;props&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;super&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;props&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;state&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="na"&gt;date&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nb"&gt;Date&lt;/span&gt;&lt;span class="p"&gt;()};&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;

  &lt;span class="nx"&gt;render&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;
      &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nt"&gt;div&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
        &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nt"&gt;h1&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;Hello, world!&lt;span class="p"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nt"&gt;h1&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
        &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nt"&gt;h2&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;It is &lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;state&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;date&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;toLocaleTimeString&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;.&lt;span class="p"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nt"&gt;h2&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
      &lt;span class="p"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nt"&gt;div&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nx"&gt;ReactDOM&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;render&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
  &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;Clock&lt;/span&gt; &lt;span class="p"&gt;/&amp;gt;,&lt;/span&gt;
  &lt;span class="nb"&gt;document&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;getElementById&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;root&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;This class renders a clock that displays the current hour in &lt;code&gt;HH:MM:SS&lt;/code&gt; format to a page. Let's break it piece by piece, starting first with the virtual DOM rendering:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight jsx"&gt;&lt;code&gt;&lt;span class="nx"&gt;ReactDOM&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;render&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
  &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;Clock&lt;/span&gt; &lt;span class="p"&gt;/&amp;gt;,&lt;/span&gt;
  &lt;span class="nb"&gt;document&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;getElementById&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;root&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;We've seen this before, this is how we place components on the DOM. Let's disregard it, since placing components on the virtual DOM is the same in functional and class components.  Removing it, then, leaves us with:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight jsx"&gt;&lt;code&gt;&lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nx"&gt;Clock&lt;/span&gt; &lt;span class="kd"&gt;extends&lt;/span&gt; &lt;span class="nx"&gt;React&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;Component&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;constructor&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;props&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;super&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;props&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;state&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="na"&gt;date&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nb"&gt;Date&lt;/span&gt;&lt;span class="p"&gt;()};&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;

  &lt;span class="nx"&gt;render&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;
      &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nt"&gt;div&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
        &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nt"&gt;h1&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;Hello, world!&lt;span class="p"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nt"&gt;h1&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
        &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nt"&gt;h2&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;It is &lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;state&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;date&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;toLocaleTimeString&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;.&lt;span class="p"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nt"&gt;h2&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
      &lt;span class="p"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nt"&gt;div&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;h3&gt;
  
  
  The Breakdown
&lt;/h3&gt;

&lt;p&gt;The first part of the component is its definition - &lt;code&gt;class Clock extends React.Component&lt;/code&gt;. This just means we're using an existing thing from React - the &lt;code&gt;Component&lt;/code&gt; class - as the basis for our class. This allows use to create our class by basing it on a set of features React offers in the &lt;code&gt;Component&lt;/code&gt; class. Moving on:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight javascript"&gt;&lt;code&gt;  &lt;span class="kd"&gt;constructor&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;props&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;super&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;props&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;state&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="na"&gt;date&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nb"&gt;Date&lt;/span&gt;&lt;span class="p"&gt;()};&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;A &lt;code&gt;constructor&lt;/code&gt; is a special function that is called when the class is instantiated - in our case, when the component is evaluated by React before being placed on the DOM. The &lt;code&gt;props&lt;/code&gt; are the attributes we've seen passed to components in the previous example - e.g. in &lt;code&gt;&amp;lt;MainInfo participantName="tom"/&amp;gt;&lt;/code&gt;, the &lt;code&gt;MainInfo&lt;/code&gt; component's &lt;code&gt;participantName&lt;/code&gt; prop has the value &lt;code&gt;tom&lt;/code&gt;. The reason we're passing the props to the constructor is so we can have access to them inside the component - otherwise we will not be able to know that &lt;code&gt;participantName&lt;/code&gt; had the value &lt;code&gt;tom&lt;/code&gt; when the component is mounted, making it difficult for us to display it on the page, for example.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;super(props)&lt;/code&gt; is another special function that calls the constructor of the &lt;em&gt;upper&lt;/em&gt; class our class is extened from - i.e. &lt;code&gt;React.Component&lt;/code&gt;. We do that to make sure the concept of props works correctly in our class component, &lt;a href="https://reactjs.org/docs/react-component.html#constructor"&gt;as explained here&lt;/a&gt;. &lt;/p&gt;

&lt;p&gt;Finally, &lt;code&gt;this.state = {date: new Date()}&lt;/code&gt; can be formatted a bit differently for better legibility:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;state&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; 
&lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="na"&gt;date&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nb"&gt;Date&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Which means we're assigning &lt;code&gt;this&lt;/code&gt; - i.e. our class &lt;code&gt;Clock&lt;/code&gt; - a property called &lt;code&gt;state&lt;/code&gt; (yes, like in the &lt;code&gt;useState()&lt;/code&gt; hook), that is a &lt;a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object"&gt;JavaScript Object&lt;/a&gt; that contains a single field &lt;code&gt;date&lt;/code&gt;. We then set this field to contain the current date (&lt;code&gt;new Date()&lt;/code&gt; returns the current date and time). So, what we're basically doing is initializing the state of the object with a single element - the current time.&lt;/p&gt;

&lt;p&gt;This is a common pattern in class constructors. We can then change the state by calling a special function called &lt;code&gt;setState()&lt;/code&gt; (more about it &lt;a href="https://reactjs.org/docs/react-component.html#setstate"&gt;here&lt;/a&gt; - it works like the handler function from &lt;code&gt;useState()&lt;/code&gt; we've seen in the previous section), and access any elements in the &lt;code&gt;state&lt;/code&gt; of the class by using &lt;code&gt;this.state.X&lt;/code&gt; (like in our example - more on this below).&lt;/p&gt;

&lt;p&gt;Moving on:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight jsx"&gt;&lt;code&gt;&lt;span class="nx"&gt;render&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;
      &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nt"&gt;div&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
        &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nt"&gt;h1&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;Hello, world!&lt;span class="p"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nt"&gt;h1&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
        &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nt"&gt;h2&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;It is &lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;state&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;date&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;toLocaleTimeString&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;.&lt;span class="p"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nt"&gt;h2&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
      &lt;span class="p"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nt"&gt;div&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;This part determines what the component does - i.e. how it looks like when rendered. The &lt;code&gt;render()&lt;/code&gt; and &lt;code&gt;return()&lt;/code&gt; parts are just React's way of saying - this is how the component is going to look like when presented. The interesting part is the JSX (we talked about it previously) between the parantheses of &lt;code&gt;return()&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight jsx"&gt;&lt;code&gt;      &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nt"&gt;div&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
        &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nt"&gt;h1&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;Hello, world!&lt;span class="p"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nt"&gt;h1&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
        &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nt"&gt;h2&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;It is &lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;state&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;date&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;toLocaleTimeString&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;.&lt;span class="p"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nt"&gt;h2&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
      &lt;span class="p"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nt"&gt;div&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;This is what the component is going to actually look like - two headers, the first of which is static and the second one referencing the &lt;code&gt;date&lt;/code&gt; element in our &lt;code&gt;state&lt;/code&gt;. Specifically, we'd like to extract the time in the user's time zone, which is what &lt;code&gt;date.toLocaleTimeString()&lt;/code&gt; does.&lt;/p&gt;

&lt;p&gt;Phew, that was a bit long, but I hope you got a good sense of what a class component looks like in practice. I'd like to make just a final note on lifecycle methods and nip this in the bud:&lt;/p&gt;

&lt;h2&gt;
  
  
  The React Component Lifecycle
&lt;/h2&gt;

&lt;p&gt;We are going to add one small thing to our class component - a &lt;a href="https://reactjs.org/docs/state-and-lifecycle.html#adding-lifecycle-methods-to-a-class"&gt;lifecycle method&lt;/a&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nx"&gt;componentDidMount&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Clock has mounted, dude!&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;So our full component is:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight jsx"&gt;&lt;code&gt;&lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nx"&gt;Clock&lt;/span&gt; &lt;span class="kd"&gt;extends&lt;/span&gt; &lt;span class="nx"&gt;React&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;Component&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;constructor&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;props&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;super&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;props&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;state&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="na"&gt;date&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nb"&gt;Date&lt;/span&gt;&lt;span class="p"&gt;()};&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nx"&gt;componentDidMount&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Clock has mounted, dude!&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

  &lt;span class="nx"&gt;render&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;
      &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nt"&gt;div&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
        &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nt"&gt;h1&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;Hello, world!&lt;span class="p"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nt"&gt;h1&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
        &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nt"&gt;h2&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;It is &lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;state&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;date&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;toLocaleTimeString&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;.&lt;span class="p"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nt"&gt;h2&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
      &lt;span class="p"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nt"&gt;div&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;All this does is log a message in the console when our clock component is being added to the DOM (i.e. when it is &lt;em&gt;mounted&lt;/em&gt;). These type of methods allow us to have a finer control of what happens when our component's status changes. Why is this useful, you ask? To me, it's kinda tricky to explain this out of the context of a full application. We will see an example of this being used in the final application I'm building in this series, but for now it's enough to say that it's really convenient to be able to know when a component has entered and left the DOM.&lt;/p&gt;

&lt;h2&gt;
  
  
  Final words
&lt;/h2&gt;

&lt;p&gt;This is all I have to say about React itself in the context of this tutorial. This is only the tip of the iceberg, as React is a somewhat advanced framework - but should give you at least &lt;em&gt;some&lt;/em&gt; intro into what it is you're looking at when reading React code. I do recommend you go buy &lt;a href="https://daveceddia.com/pure-react/?utm_source=tom"&gt;Dave Ceddia's Pure React&lt;/a&gt; - it taught me most of what I use in my apps, and the guy is still updating it today! Hey Dave, if you're reading this, thank you for an awesome book! :)&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>react</category>
      <category>shopify</category>
      <category>shopifyapps</category>
    </item>
    <item>
      <title>Shopify App From Scratch #8 - React Sidestep 2</title>
      <dc:creator>Red Cap Tom</dc:creator>
      <pubDate>Sat, 06 Jun 2020 17:05:27 +0000</pubDate>
      <link>https://forem.com/redcaptom/shopify-app-from-scratch-8-react-sidestep-2-53cl</link>
      <guid>https://forem.com/redcaptom/shopify-app-from-scratch-8-react-sidestep-2-53cl</guid>
      <description>&lt;h2&gt;
  
  
  Deprecation Notice
&lt;/h2&gt;

&lt;p&gt;Yeah, yeah, I know. I hate it too when people abandon tutorial series mid-way. But, due to (exciting!) circumstances, I'm calling it quits for now.&lt;/p&gt;

&lt;p&gt;I'm thinking of just dropping a link to the full repo here - it's a mess, but it's something you guys can chew on instead of my empty promises.&lt;/p&gt;

&lt;p&gt;If you'd like me to drop it here - let me know at &lt;a href="mailto:hey@redcaptom.com"&gt;hey@redcaptom.com&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;And, just sayin', I had a BLAST doing this. If you know something - anything - about technology, take the time to write it down as a tutorial series. You will get SO, SO much value out of it, you can't even believe it.&lt;/p&gt;

&lt;p&gt;Until we meet again - RCT :)&lt;/p&gt;

&lt;h2&gt;
  
  
  The Video (Scroll down for the article)
&lt;/h2&gt;

&lt;p&gt;Coming soon!&lt;/p&gt;

&lt;h2&gt;
  
  
  A Short Primer
&lt;/h2&gt;

&lt;p&gt;Before we dive into it, It's important to note that React is just JavaScript. Facebook wrote React as a JavaScript library that deals with scaffolding up the front-end part of a website. This means that you should probably know &lt;em&gt;some&lt;/em&gt; JavaScript before you enter this sidestep. If you don't know &lt;em&gt;any&lt;/em&gt; javascript, as in you've never written a line of it, go &lt;a href="https://www.codecademy.com/learn/introduction-to-javascript" rel="noopener noreferrer"&gt;do a tutorial&lt;/a&gt; and come back.&lt;/p&gt;

&lt;p&gt;Keep in mind that this is just a sidestep - it's not actually a tutorial. It's something that is done in order to familiarize you with the concepts that I'm talking about, so when you look at a syntax or when I'm running through the application we're going to build, you have some idea of what I'm talking about. It's not meant to teach you React - it's just meant to give you a taste of it, and maybe give you some terms you can later Google and dive into properly.&lt;/p&gt;

&lt;p&gt;Before we actually install React and play with it a bit, I do want to mention one thing. React, by itself, has two "worlds" in it. The first one, what people usually talk about when they talk about React, is &lt;a href="https://www.codecademy.com/learn/introduction-to-javascript" rel="noopener noreferrer"&gt;JSX&lt;/a&gt; - which is what React components are &lt;em&gt;returning&lt;/em&gt; - which kind of looks like HTML and not really like JavaScript. This can be confusing to people. What you should know is React is kind of half-and-half in that sense - one part is what you return to the page (JSX) and a second part is in charge of &lt;em&gt;what&lt;/em&gt;, &lt;em&gt;where&lt;/em&gt; and &lt;em&gt;when&lt;/em&gt; the former JSX gets thrown up on the page. &lt;/p&gt;

&lt;p&gt;This is a bit "in the air", and therefore I'd like to dive in and explain as I go along.&lt;/p&gt;

&lt;h2&gt;
  
  
  Setting up
&lt;/h2&gt;

&lt;p&gt;Given that React is a JavaScript framework, we will use stuff from the JavaScript ecosystem. Specifically, if you come from a a PHP or ASP or those kind of languages, you're used to spinning up a server and putting your stuff there in order to see them run.&lt;/p&gt;

&lt;p&gt;If you're on Windows it's probably &lt;a href="https://www.apachefriends.org/index.html" rel="noopener noreferrer"&gt;XAMPP&lt;/a&gt;, if you're on a Mac it's probably &lt;a href="https://www.mamp.info/en/windows/" rel="noopener noreferrer"&gt;MAMP&lt;/a&gt; and if you're on Linux you probably roll your own configuration. Anyways, what you probably do is running a server (i.e. Apache), putting files in the exposed folder in that server (i.e. &lt;code&gt;htdocs&lt;/code&gt; or &lt;code&gt;www&lt;/code&gt;) and then serving those files from there by opening your browser to that location. &lt;/p&gt;

&lt;p&gt;The JavaScript frameworks usually have a bundled-in server which is very similar to running XAMPP locally, except for the fact that the framework takes care of everything for you.&lt;/p&gt;

&lt;p&gt;This is a theme that will become more and more apparent as you dive deeper and deeper into JavaScript frameworks. They have a tendency to do everything for you - lots of packages, lots of stuff out there to save you time and headaches. Everything you can think of - from testing to linting to deploying to... you name it - they have it. This makes the entire "getting started" phase of a project really really fast.&lt;/p&gt;

&lt;p&gt;We're going to dive right in. First things first - let's make sure we got the correct version for the project in front of us. This can be done using &lt;code&gt;nvm&lt;/code&gt; - Node Version Manager - which we have installed previously. The command &lt;code&gt;nvm use&lt;/code&gt; tells &lt;code&gt;nvm&lt;/code&gt; to "switch the context" to the correct version of Node. I used V12.13.1 of Node for this project, so we can do:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;nvm use 12.13.1
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;To get the correct version for this project, and you should see a success message telling you that you are now using the correct version. If you don't have that version installed, just do:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;nvm &lt;span class="nb"&gt;install &lt;/span&gt;12.13.1
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Scaffolding the project
&lt;/h2&gt;

&lt;p&gt;To get it. We're now going to use &lt;code&gt;npx&lt;/code&gt; - which is kind of like a sister tool to &lt;code&gt;npm&lt;/code&gt; - that is used to run executables in packages. The actual stuff going on behind the scenes don't really matter right now - it is just used for installation of a scaffolding tool for React called &lt;a href="https://create-react-app.dev/" rel="noopener noreferrer"&gt;&lt;code&gt;create-react-app&lt;/code&gt;&lt;/a&gt;. It feels like a build tool for React but that's not really what it does - a better term for it will be a "Scaffolder", so that's what I'm going to use. Run the following to create a new project called &lt;code&gt;react-sidestep&lt;/code&gt;, since that's what we are doing right now:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npx create-react-app react-sidestep
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;It's gonna take a while. If you watch the video, I go most of what the script installed. I think it's a great overview for what is available out of the box with this scaffolding tool.&lt;/p&gt;

&lt;p&gt;Note that this created a new folder in the directory you were in called &lt;code&gt;react-sidestep&lt;/code&gt;. Go into it by running:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;cd &lt;/span&gt;react-sidestep
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;we can now actually run our newly-scaffolded React app by doing:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npm start
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And see the following screen pop up in front of us:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fqiz1i71vgpb1xk328eel.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fqiz1i71vgpb1xk328eel.png" alt="react-main-screen"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;You might note that there are a bunch of files in that folder - see the video for an exact breakdown of what each of the files is actually all about. I also go quite deeply into the JavaScript ecosystem, &lt;code&gt;npm&lt;/code&gt; and various interesting things around developing in modern JavaScript.&lt;/p&gt;

&lt;h2&gt;
  
  
  In Comes React
&lt;/h2&gt;

&lt;p&gt;But, let's get down to business - how React actually looks like in the wild. Let's take a look at the &lt;code&gt;src&lt;/code&gt; folder:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;src
--| App.css
--| App.js
--| App.test.js
--| index.css
--| index.js
--| logo.svg
--| serviceWorker.js
--| setupTests.js
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The entry point to the app - and the interesting tidbit from our end - is &lt;code&gt;index.js&lt;/code&gt;, so this is what I'm going to focus on:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;React&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;react&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;ReactDOM&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;react-dom&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;./index.css&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;App&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;./App&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="nx"&gt;serviceWorker&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;./serviceWorker&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="nx"&gt;ReactDOM&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;render&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
  &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;React&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;StrictMode&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;App&lt;/span&gt; &lt;span class="o"&gt;/&amp;gt;&lt;/span&gt;
  &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/React.StrictMode&amp;gt;&lt;/span&gt;&lt;span class="err"&gt;,
&lt;/span&gt;  &lt;span class="nb"&gt;document&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;getElementById&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;root&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;);&lt;/span&gt;

&lt;span class="c1"&gt;// If you want your app to work offline and load faster, you can change&lt;/span&gt;
&lt;span class="c1"&gt;// unregister() to register() below. Note this comes with some pitfalls.&lt;/span&gt;
&lt;span class="c1"&gt;// Learn more about service workers: https://bit.ly/CRA-PWA&lt;/span&gt;
&lt;span class="nx"&gt;serviceWorker&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;unregister&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Let's break it bit by bit - the first thing you see is the imports:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;React&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;react&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;ReactDOM&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;react-dom&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;./index.css&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;App&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;./App&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="nx"&gt;serviceWorker&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;./serviceWorker&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Those imports are either coming from the &lt;code&gt;node_modules&lt;/code&gt; folder (i.e. were installed in by definition in the &lt;code&gt;package.json&lt;/code&gt; file and/or by &lt;code&gt;npm install &amp;lt;package&amp;gt;&lt;/code&gt;), or local files. You can separate the two by the &lt;code&gt;./&lt;/code&gt; before local files, whereas &lt;code&gt;npm&lt;/code&gt; packages just have the package name as the origin of the import.&lt;/p&gt;

&lt;p&gt;So &lt;code&gt;react&lt;/code&gt; and &lt;code&gt;react-dom&lt;/code&gt; are both both packages that are inside the &lt;code&gt;node_modules&lt;/code&gt; folder, whereas everything else is originating in some local folder or file inside our project.&lt;/p&gt;

&lt;p&gt;The interesting part comes now:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nx"&gt;ReactDOM&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;render&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
  &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;React&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;StrictMode&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;App&lt;/span&gt; &lt;span class="o"&gt;/&amp;gt;&lt;/span&gt;
  &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/React.StrictMode&amp;gt;&lt;/span&gt;&lt;span class="err"&gt;,
&lt;/span&gt;  &lt;span class="nb"&gt;document&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;getElementById&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;root&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;React doesn't actually populate HTML tags into your page. What React does is simulate a &lt;a href="https://developer.mozilla.org/en-US/docs/Web/API/Document_Object_Model/Introduction" rel="noopener noreferrer"&gt;DOM&lt;/a&gt; - the representation of things on a web page - and maintains it completely independently of the actual DOM you see on the page. That DOM is called a &lt;a href="https://reactjs.org/docs/faq-internals.html" rel="noopener noreferrer"&gt;Virtual DOM&lt;/a&gt;, and it is the best mapping React can create to simulate the behavior you expect to see on a page.&lt;/p&gt;

&lt;p&gt;In order to actually understand what this means, let's skip over to the &lt;code&gt;public/index.html&lt;/code&gt; file for a second:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="cp"&gt;&amp;lt;!DOCTYPE html&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;html&lt;/span&gt; &lt;span class="na"&gt;lang=&lt;/span&gt;&lt;span class="s"&gt;"en"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;head&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;meta&lt;/span&gt; &lt;span class="na"&gt;charset=&lt;/span&gt;&lt;span class="s"&gt;"utf-8"&lt;/span&gt; &lt;span class="nt"&gt;/&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;link&lt;/span&gt; &lt;span class="na"&gt;rel=&lt;/span&gt;&lt;span class="s"&gt;"icon"&lt;/span&gt; &lt;span class="na"&gt;href=&lt;/span&gt;&lt;span class="s"&gt;"%PUBLIC_URL%/favicon.ico"&lt;/span&gt; &lt;span class="nt"&gt;/&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;meta&lt;/span&gt; &lt;span class="na"&gt;name=&lt;/span&gt;&lt;span class="s"&gt;"viewport"&lt;/span&gt; &lt;span class="na"&gt;content=&lt;/span&gt;&lt;span class="s"&gt;"width=device-width, initial-scale=1"&lt;/span&gt; &lt;span class="nt"&gt;/&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;meta&lt;/span&gt; &lt;span class="na"&gt;name=&lt;/span&gt;&lt;span class="s"&gt;"theme-color"&lt;/span&gt; &lt;span class="na"&gt;content=&lt;/span&gt;&lt;span class="s"&gt;"#000000"&lt;/span&gt; &lt;span class="nt"&gt;/&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;meta&lt;/span&gt;
      &lt;span class="na"&gt;name=&lt;/span&gt;&lt;span class="s"&gt;"description"&lt;/span&gt;
      &lt;span class="na"&gt;content=&lt;/span&gt;&lt;span class="s"&gt;"Web site created using create-react-app"&lt;/span&gt;
    &lt;span class="nt"&gt;/&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;link&lt;/span&gt; &lt;span class="na"&gt;rel=&lt;/span&gt;&lt;span class="s"&gt;"apple-touch-icon"&lt;/span&gt; &lt;span class="na"&gt;href=&lt;/span&gt;&lt;span class="s"&gt;"%PUBLIC_URL%/logo192.png"&lt;/span&gt; &lt;span class="nt"&gt;/&amp;gt;&lt;/span&gt;
    &lt;span class="c"&gt;&amp;lt;!--
      manifest.json provides metadata used when your web app is installed on a
      user's mobile device or desktop. See https://developers.google.com/web/fundamentals/web-app-manifest/
    --&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;link&lt;/span&gt; &lt;span class="na"&gt;rel=&lt;/span&gt;&lt;span class="s"&gt;"manifest"&lt;/span&gt; &lt;span class="na"&gt;href=&lt;/span&gt;&lt;span class="s"&gt;"%PUBLIC_URL%/manifest.json"&lt;/span&gt; &lt;span class="nt"&gt;/&amp;gt;&lt;/span&gt;
    &lt;span class="c"&gt;&amp;lt;!--
      Notice the use of %PUBLIC_URL% in the tags above.
      It will be replaced with the URL of the `public` folder during the build.
      Only files inside the `public` folder can be referenced from the HTML.

      Unlike "/favicon.ico" or "favicon.ico", "%PUBLIC_URL%/favicon.ico" will
      work correctly both with client-side routing and a non-root public URL.
      Learn how to configure a non-root public URL by running `npm run build`.
    --&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;title&amp;gt;&lt;/span&gt;React App&lt;span class="nt"&gt;&amp;lt;/title&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;/head&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;body&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;noscript&amp;gt;&lt;/span&gt;You need to enable JavaScript to run this app.&lt;span class="nt"&gt;&amp;lt;/noscript&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;div&lt;/span&gt; &lt;span class="na"&gt;id=&lt;/span&gt;&lt;span class="s"&gt;"root"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&amp;lt;/div&amp;gt;&lt;/span&gt;
    &lt;span class="c"&gt;&amp;lt;!--
      This HTML file is a template.
      If you open it directly in the browser, you will see an empty page.

      You can add webfonts, meta tags, or analytics to this file.
      The build step will place the bundled scripts into the &amp;lt;body&amp;gt; tag.

      To begin the development, run `npm start` or `yarn start`.
      To create a production bundle, use `npm run build` or `yarn build`.
    --&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;/body&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/html&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Specifically, take a look at this part:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;    &lt;span class="nt"&gt;&amp;lt;div&lt;/span&gt; &lt;span class="na"&gt;id=&lt;/span&gt;&lt;span class="s"&gt;"root"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&amp;lt;/div&amp;gt;&lt;/span&gt;
    &lt;span class="c"&gt;&amp;lt;!--
      This HTML file is a template.
      If you open it directly in the browser, you will see an empty page.

      You can add webfonts, meta tags, or analytics to this file.
      The build step will place the bundled scripts into the &amp;lt;body&amp;gt; tag.

      To begin the development, run `npm start` or `yarn start`.
      To create a production bundle, use `npm run build` or `yarn build`.
    --&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This basically explains the whole thing - React takes care of maintaining some representation of the optimal DOM somewhere in memory, and then adds / remove HTML elements from the page accordingly. Specifically, you can tell it to start adding/removing elements from a &lt;strong&gt;specific place in the page&lt;/strong&gt;, and the most common location to do that is an HTML &lt;code&gt;&amp;lt;div&amp;gt;&lt;/code&gt; element with the id of &lt;code&gt;root&lt;/code&gt;. Back to our JavaScript for a second:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nx"&gt;ReactDOM&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;render&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
  &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;React&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;StrictMode&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;App&lt;/span&gt; &lt;span class="o"&gt;/&amp;gt;&lt;/span&gt;
  &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/React.StrictMode&amp;gt;&lt;/span&gt;&lt;span class="err"&gt;,
&lt;/span&gt;  &lt;span class="nb"&gt;document&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;getElementById&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;root&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;It might make a bit more sense to you now - we're telling &lt;code&gt;ReactDOM&lt;/code&gt; to "render" - i.e. throw on the page - something that looks like three HTML tags (but is actually JSX, and we'll talk about that in a second), and then &lt;strong&gt;place them&lt;/strong&gt; inside the &lt;code&gt;root&lt;/code&gt; HTML element. This, in essence, means that React will "push" into the &lt;code&gt;&amp;lt;div&amp;gt;&lt;/code&gt; whatever it is we ask it to push, and in our specific case it will push:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight jsx"&gt;&lt;code&gt;  &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;React&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;StrictMode&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;App&lt;/span&gt; &lt;span class="p"&gt;/&amp;gt;&lt;/span&gt;
  &lt;span class="p"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nc"&gt;React&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;StrictMode&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Under the &lt;code&gt;root&lt;/code&gt; element. Note that this is very different than what you might be used to - it's, conceptually at least, "offloading" the creating of the webpage to React. I think it's a great abstraction over what I was previosuly used to, but that's of course up for debate:)&lt;/p&gt;

&lt;h2&gt;
  
  
  Funcational Components
&lt;/h2&gt;

&lt;p&gt;So what is this mystical JSX that I keep on talking about?&lt;/p&gt;

&lt;p&gt;Well, in essence - it &lt;em&gt;is&lt;/em&gt; JavaScript. It is a "syntax extension" - which is a fancy way of saying "let's add more words to our language's dictionary" - that allows us to use actual logic when creating our interfaces.&lt;/p&gt;

&lt;p&gt;You can have functions, variables, conditionals and other fun things you're used to from your favorite programming langugaes &lt;em&gt;right in JSX&lt;/em&gt; - enabling you to refrain from mixing-and-matching PHP, JavaScript and HTML to create screens.&lt;/p&gt;

&lt;p&gt;Most of React revolves around "Components" - which are logical pieces of interface that can be swapped around your page, re-used, re-purposed and basically encapsulate everything your interface's "meat".&lt;/p&gt;

&lt;p&gt;In our case, &lt;code&gt;&amp;lt;App&amp;gt;&lt;/code&gt; is a component - and in actuality the main component of our app. This very similiar, conceptually, to creating custom HTML tags - each representing a set of interface parts grouped together to perform some logic. You will see &lt;code&gt;&amp;lt;Button&amp;gt;&lt;/code&gt; and &lt;code&gt;&amp;lt;TextField&amp;gt;&lt;/code&gt; components, &lt;code&gt;&amp;lt;Slider&amp;gt;&lt;/code&gt; and &lt;code&gt;&amp;lt;Navbar&amp;gt;&lt;/code&gt; components and - like here - more fully-featured, complete components like &lt;code&gt;&amp;lt;App&amp;gt;&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;&amp;lt;App&amp;gt;&lt;/code&gt; is coming from an import, and is actually defined in the &lt;code&gt;App.js&lt;/code&gt; file. Let's take a look to see what this component actually looks like:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;React&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;react&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;logo&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;./logo.svg&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;./App.css&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;App&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;return &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;div&lt;/span&gt; &lt;span class="nx"&gt;className&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;App&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
      &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;header&lt;/span&gt; &lt;span class="nx"&gt;className&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;App-header&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
        &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;img&lt;/span&gt; &lt;span class="nx"&gt;src&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;logo&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="nx"&gt;className&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;App-logo&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="nx"&gt;alt&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;logo&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="o"&gt;/&amp;gt;&lt;/span&gt;
        &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;p&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
          &lt;span class="nx"&gt;Edit&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;code&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="nx"&gt;src&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="nx"&gt;App&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;js&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/code&amp;gt; and save to reload&lt;/span&gt;&lt;span class="err"&gt;.
&lt;/span&gt;        &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/p&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;        &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;a&lt;/span&gt;
          &lt;span class="nx"&gt;className&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;App-link&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;
          &lt;span class="nx"&gt;href&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;https://reactjs.org&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;
          &lt;span class="nx"&gt;target&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;_blank&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;
          &lt;span class="nx"&gt;rel&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;noopener noreferrer&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;
        &lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
          &lt;span class="nx"&gt;Learn&lt;/span&gt; &lt;span class="nx"&gt;React&lt;/span&gt;
        &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/a&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;      &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/header&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;    &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/div&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;  &lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="k"&gt;default&lt;/span&gt; &lt;span class="nx"&gt;App&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;It seems to revolve around this &lt;code&gt;App()&lt;/code&gt; function, right? That is no coincidence, and that is the first type of component I will talk about - a &lt;a href="https://www.robinwieruch.de/react-function-component" rel="noopener noreferrer"&gt;functional component&lt;/a&gt;. This might seem a bit weird at first - is this a component, or a function?&lt;/p&gt;

&lt;p&gt;Well, as you'll soon see, every component in React is either a function or a class (more about that in the next article in the series). In and of itself, this should not matter to you. All you should understand is that each thing that you see on a page is a function, and understand how those functions compose together to create the UI.&lt;/p&gt;

&lt;p&gt;Notice that the &lt;code&gt;App()&lt;/code&gt; function is kind of simple - it just has a return clause, that returns a bunch of JSX (which, in this case, is mostly valid HTML). The only weird looking thing is this part:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight jsx"&gt;&lt;code&gt;&lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nt"&gt;img&lt;/span&gt; &lt;span class="na"&gt;src&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;logo&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt; &lt;span class="na"&gt;className&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"App-logo"&lt;/span&gt; &lt;span class="na"&gt;alt&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"logo"&lt;/span&gt; &lt;span class="p"&gt;/&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;What is this &lt;code&gt;{logo}&lt;/code&gt; thing doing there? Well, that's the beauty of JSX for you - it's a javascript variable defined here:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight jsx"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;logo&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;./logo.svg&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Which gets the SVG logo from the file (&lt;a href="https://create-react-app.dev/docs/adding-images-fonts-and-files/" rel="noopener noreferrer"&gt;streamlined by &lt;code&gt;create-react-app&lt;/code&gt;&lt;/a&gt;) for you to use inside your component. This means that the React logo you saw on the initial screen, is actually imported right here in the component for display!&lt;/p&gt;

&lt;p&gt;The rest of the JSX is just valid HTML. Whenever the &lt;code&gt;App&lt;/code&gt; component is will be called, like in &lt;code&gt;index.js&lt;/code&gt; as we saw before:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight jsx"&gt;&lt;code&gt;  &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;React&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;StrictMode&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;App&lt;/span&gt; &lt;span class="p"&gt;/&amp;gt;&lt;/span&gt;
  &lt;span class="p"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nc"&gt;React&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;StrictMode&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;React will make sure to place all the JSX returned by the element into is virtual DOM. In this case, &lt;code&gt;App&lt;/code&gt; is a rather simple component - but we'll see in a second the power this approach brings us when the component are a bit more complex.&lt;/p&gt;

&lt;p&gt;There is one small difference to note here - the &lt;code&gt;class&lt;/code&gt; attribute of HTML tags needs to be swapped for &lt;code&gt;className&lt;/code&gt; in JSX. This eventually get massaged into the &lt;code&gt;class&lt;/code&gt; attribute you know and love, but it's important to mention the very obvious difference from plain HTML.&lt;/p&gt;

&lt;p&gt;If you're following along with the video, I stop here to give an example of how to break apart a single component into multiple ones, talk about &lt;a href="https://reactjs.org/docs/fragments.html" rel="noopener noreferrer"&gt;React Fragments&lt;/a&gt; and mess with the default project a bit to show you what's possible.&lt;/p&gt;

&lt;h2&gt;
  
  
  Props
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://reactjs.org/docs/components-and-props.html" rel="noopener noreferrer"&gt;Props&lt;/a&gt;. are values you can pass to a component, and then render different things based on them. For example, in the video I add a &lt;code&gt;participantName&lt;/code&gt; prop to the &lt;code&gt;MainInfo&lt;/code&gt; component I created. I can then pass to the component &lt;em&gt;different&lt;/em&gt; attribute values in different parts of the app. This enables me, for example, to call that component once for a participant named "Tom" and once for a participant named "Not Tom". Both participants will get their own &lt;code&gt;MainInfo&lt;/code&gt; component, with the name swapped out based on the value provided to the attribute. &lt;/p&gt;

&lt;h2&gt;
  
  
  Hooks
&lt;/h2&gt;

&lt;p&gt;React hooks are... a bit tricky. I give an example in the video to a simple hook, but in retrospective I advise you to read the &lt;a href="https://reactjs.org/docs/hooks-intro.html" rel="noopener noreferrer"&gt;React Hooks&lt;/a&gt; intro and &lt;a href="https://reactjs.org/docs/hooks-overview.html" rel="noopener noreferrer"&gt;Hooks at a Glance&lt;/a&gt; for a better overview. They're short and concise, and give you all you need to understand about the syntax to get going, in my opinion.&lt;/p&gt;

&lt;h2&gt;
  
  
  Final words
&lt;/h2&gt;

&lt;p&gt;This was a very short overview of functional components and the basics of React. Make sure to read the next article in the series to learn about class components, and - if you'd like a deeper dive - check out Dave Ceddia's &lt;a href="https://daveceddia.com/pure-react/?utm_source=tom" rel="noopener noreferrer"&gt;Pure React&lt;/a&gt; book for a more thorough walk through React. This might look like an affiliate link, btw, but it's just a way for me and Dave to track how many visitors I'm sending his way (no money involved).&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>react</category>
      <category>shopify</category>
      <category>shopifyapps</category>
    </item>
    <item>
      <title>Shopify App From Scratch #7 - React Sidestep 1</title>
      <dc:creator>Red Cap Tom</dc:creator>
      <pubDate>Fri, 29 May 2020 00:41:54 +0000</pubDate>
      <link>https://forem.com/redcaptom/shopify-app-from-scratch-7-react-sidestep-1-1pgd</link>
      <guid>https://forem.com/redcaptom/shopify-app-from-scratch-7-react-sidestep-1-1pgd</guid>
      <description>&lt;h2&gt;
  
  
  Deprecation Notice
&lt;/h2&gt;

&lt;p&gt;Yeah, yeah, I know. I hate it too when people abandon tutorial series mid-way. But, due to (exciting!) circumstances, I'm calling it quits for now.&lt;/p&gt;

&lt;p&gt;I'm thinking of just dropping a link to the full repo here - it's a mess, but it's something you guys can chew on instead of my empty promises.&lt;/p&gt;

&lt;p&gt;If you'd like me to drop it here - let me know at &lt;a href="mailto:hey@redcaptom.com"&gt;hey@redcaptom.com&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;And, just sayin', I had a BLAST doing this. If you know something - anything - about technology, take the time to write it down as a tutorial series. You will get SO, SO much value out of it, you can't even believe it.&lt;/p&gt;

&lt;p&gt;Until we meet again - RCT :)&lt;/p&gt;

&lt;h2&gt;
  
  
  The Video (Scroll down for the article)
&lt;/h2&gt;

&lt;p&gt;Coming soon!&lt;/p&gt;

&lt;h2&gt;
  
  
  Why React?
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Frz6th6azjcnke8atked3.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Frz6th6azjcnke8atked3.png" alt="react-logo"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;All right, so why should you even take the time to learn a new JS framework? If you're like me, you come from a PHP background, and grew up writing applications that consist of a php file that is generated dynamically from the server. If there's some form on the page, then when the user clicks it - the information gets send back to the sever, and the page gets rendered again (possibly with newer information). This used to be enough for a very, very long while.&lt;/p&gt;

&lt;p&gt;It is no longer enough, though. When I'm looking at applications today, they're less like the web sites we had growing up, and more like our desktop applications, right? And the reaction I get when I tell people they should learn React is "I already know PHP, and maybe even some jQuery - why do I need React?".&lt;/p&gt;

&lt;p&gt;The honest answer is that you really don't have to learn React. The kind of fuller answer is that if you want to match the experience that other web sites are providing for their users, you might want to consider adapting the same technologies that they are accustomed to dealing with.&lt;/p&gt;

&lt;p&gt;As you probably already know, copy-pasting in the exact same way from other people's work is kinda problematic. What is perfectly OK is to draw inspiration from the &lt;em&gt;feel&lt;/em&gt; other makers imbue their products with, and &lt;em&gt;strive&lt;/em&gt; for the same aesthetic in your stuff.&lt;/p&gt;

&lt;p&gt;Remember the end user of your application? All they probably care about is that your app feels comfortable, familiar and that it &lt;em&gt;works&lt;/em&gt;. React, one of the main tools used in creating interactive web UIs today, can do just that for you. I think the average end users of the world would be very happy if most websites would feel and look the same from the &lt;em&gt;functionality&lt;/em&gt;'s perspective. That buttons and forms and sidebars act in the same way that they expect them to, instead of changing drastically from site to site. This lowers the technical barrier of entry into computers that a lot of people have.&lt;/p&gt;

&lt;p&gt;So you should do it for the end-users. But really, you should also do it for you. The biggest benefit of React is composability and portability of components - write it once, use it everywhere. The encapsulation of code into components allows you to easily mix&amp;amp;match parts of your application to get the feel you want, and to re-use existing components from other people with the blink of an eye. This is insanely useful, and if you're writing without it you're missing out on a great ecosystem.&lt;/p&gt;

&lt;p&gt;And honestly, it's just fun. I keep telling people that React changes the way that you think about development. I think more than any other technology that I've seen in the past, it really tries to get you to think declaratively &lt;em&gt;first&lt;/em&gt; - on the way things will &lt;em&gt;feel&lt;/em&gt;, instead of how easy it would be to build. This might not make much sense now, but bear with me - I will try to pass that sentiment on in the rest of the tutorial series, when we will actually build the app.&lt;/p&gt;

&lt;h3&gt;
  
  
  A note about these sidesteps
&lt;/h3&gt;

&lt;p&gt;Note that my sidesteps do not intend to teach you things from scratch. They're intended to give you "hooks" (mind the React pun, please :) ) to allow you to read and understand different parts of the relevant technology. I urge you to go and actually learn these concepts yourselves if you're so inclined, but still attempt to give you a "fully-featured" tutorial right here and now.&lt;/p&gt;

&lt;h2&gt;
  
  
  React Itself - In The Next Video
&lt;/h2&gt;

&lt;p&gt;I make a pretty good walkthrough of our makeshift app in the video, showing the different parts that can be made better using React. I think that the value itself will not become obvious to you until you start creating interfaces with it. After going over the initial learning curve, it's truly a remarkable piece of software to use. Follow the videos and the next two articles, and you'll begin to see the beauty:)&lt;/p&gt;

&lt;p&gt;The next video will be a bit more hands-on than this introductory one - stay tuned!&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>react</category>
      <category>shopify</category>
      <category>shopifyapps</category>
    </item>
    <item>
      <title>Shopify App From Scratch #6 - Mockup Part 2</title>
      <dc:creator>Red Cap Tom</dc:creator>
      <pubDate>Thu, 28 May 2020 23:05:28 +0000</pubDate>
      <link>https://forem.com/redcaptom/shopify-app-from-scratch-6-mockup-2-911</link>
      <guid>https://forem.com/redcaptom/shopify-app-from-scratch-6-mockup-2-911</guid>
      <description>&lt;h2&gt;
  
  
  Deprecation Notice
&lt;/h2&gt;

&lt;p&gt;Yeah, yeah, I know. I hate it too when people abandon tutorial series mid-way. But, due to (exciting!) circumstances, I'm calling it quits for now.&lt;/p&gt;

&lt;p&gt;I'm thinking of just dropping a link to the full repo here - it's a mess, but it's something you guys can chew on instead of my empty promises.&lt;/p&gt;

&lt;p&gt;If you'd like me to drop it here - let me know at &lt;a href="mailto:hey@redcaptom.com"&gt;hey@redcaptom.com&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;And, just sayin', I had a BLAST doing this. If you know something - anything - about technology, take the time to write it down as a tutorial series. You will get SO, SO much value out of it, you can't even believe it.&lt;/p&gt;

&lt;p&gt;Until we meet again - RCT :)&lt;/p&gt;

&lt;h2&gt;
  
  
  The Video (Scroll down for the article)
&lt;/h2&gt;

&lt;p&gt;Coming soon!&lt;/p&gt;

&lt;h2&gt;
  
  
  In Comes CSS
&lt;/h2&gt;

&lt;p&gt;If you follow the Video above, you'll notice that I'm building up a new HTML wireframe, that has a bunch of improvements and some custom CSS to make it prettier. Here's the new, final result:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Ftb9bim047hlrte7ufvbh.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Ftb9bim047hlrte7ufvbh.png" alt="new-wireframe"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Here's the new HTML:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;html&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;head&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;link&lt;/span&gt; &lt;span class="na"&gt;rel=&lt;/span&gt;&lt;span class="s"&gt;"stylesheet"&lt;/span&gt; &lt;span class="na"&gt;href=&lt;/span&gt;&lt;span class="s"&gt;"styles.css"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;title&amp;gt;&lt;/span&gt;
        Countries We Ship Button
    &lt;span class="nt"&gt;&amp;lt;/title&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/head&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;body&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;div&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"container"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
        &lt;span class="nt"&gt;&amp;lt;div&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"headerContainer"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
            &lt;span class="nt"&gt;&amp;lt;div&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"header"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
                &lt;span class="nt"&gt;&amp;lt;h1&amp;gt;&lt;/span&gt;Countries We Ship To Button&lt;span class="nt"&gt;&amp;lt;/h1&amp;gt;&lt;/span&gt;
            &lt;span class="nt"&gt;&amp;lt;/div&amp;gt;&lt;/span&gt;
            &lt;span class="nt"&gt;&amp;lt;div&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"prompt"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
                &lt;span class="nt"&gt;&amp;lt;p&amp;gt;&lt;/span&gt;Please select the type of button you'd like to create:&lt;span class="nt"&gt;&amp;lt;/p&amp;gt;&lt;/span&gt;
            &lt;span class="nt"&gt;&amp;lt;/div&amp;gt;&lt;/span&gt;
        &lt;span class="nt"&gt;&amp;lt;/div&amp;gt;&lt;/span&gt;
        &lt;span class="nt"&gt;&amp;lt;div&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"singleButtonType1"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
            &lt;span class="nt"&gt;&amp;lt;div&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"type1Example"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
                &lt;span class="nt"&gt;&amp;lt;button&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"type1Button"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;Countries We Ship To Button&lt;span class="nt"&gt;&amp;lt;/button&amp;gt;&lt;/span&gt;
            &lt;span class="nt"&gt;&amp;lt;/div&amp;gt;&lt;/span&gt;
            &lt;span class="nt"&gt;&amp;lt;input&lt;/span&gt; &lt;span class="na"&gt;type=&lt;/span&gt;&lt;span class="s"&gt;"checkbox"&lt;/span&gt; &lt;span class="na"&gt;value=&lt;/span&gt;&lt;span class="s"&gt;"type1"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;Type 1
        &lt;span class="nt"&gt;&amp;lt;/div&amp;gt;&lt;/span&gt;
        &lt;span class="nt"&gt;&amp;lt;div&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"singleButtonType2"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
            &lt;span class="nt"&gt;&amp;lt;div&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"type2Example"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
                &lt;span class="nt"&gt;&amp;lt;button&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"type2Button"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;Countries We Ship To Button&lt;span class="nt"&gt;&amp;lt;/button&amp;gt;&lt;/span&gt;
            &lt;span class="nt"&gt;&amp;lt;/div&amp;gt;&lt;/span&gt;
            &lt;span class="nt"&gt;&amp;lt;input&lt;/span&gt; &lt;span class="na"&gt;type=&lt;/span&gt;&lt;span class="s"&gt;"checkbox"&lt;/span&gt; &lt;span class="na"&gt;value=&lt;/span&gt;&lt;span class="s"&gt;"type2"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;Type 2
        &lt;span class="nt"&gt;&amp;lt;/div&amp;gt;&lt;/span&gt;
        &lt;span class="nt"&gt;&amp;lt;div&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"toggle"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
            &lt;span class="nt"&gt;&amp;lt;button&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"toggleButton"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;Toggle&lt;span class="nt"&gt;&amp;lt;/button&amp;gt;&lt;/span&gt;
        &lt;span class="nt"&gt;&amp;lt;/div&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;/div&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/body&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/html&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And the new CSS:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="c"&gt;/* A lot of the information can be learned from Shopify Polairs */&lt;/span&gt;
&lt;span class="c"&gt;/* Form elements use the default of the OS  */&lt;/span&gt;

&lt;span class="nt"&gt;html&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="c"&gt;/* Load system fonts */&lt;/span&gt;
    &lt;span class="nl"&gt;font-family&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;-apple-system&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;BlinkMacSystemFont&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;San&lt;/span&gt; &lt;span class="n"&gt;Francisco&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;Roboto&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;Segoe&lt;/span&gt; &lt;span class="n"&gt;UI&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;Helvetica&lt;/span&gt; &lt;span class="n"&gt;Neue&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nb"&gt;sans-serif&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="c"&gt;/* Make type rendering look crisper */&lt;/span&gt;
    &lt;span class="nl"&gt;-webkit-font-smoothing&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;antialiased&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="nl"&gt;-moz-osx-font-smoothing&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;grayscale&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="c"&gt;/* Disable auto-enlargement of small text in Safari */&lt;/span&gt;
    &lt;span class="py"&gt;text-size-adjust&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;100%&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="c"&gt;/* Enable kerning and optional ligatures */&lt;/span&gt;
    &lt;span class="nl"&gt;text-rendering&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;optimizeLegibility&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="c"&gt;/**
   * Form elements render using OS defaults,
   * so font-family inheritance must be specifically declared
   */&lt;/span&gt;

&lt;span class="nt"&gt;button&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt;
&lt;span class="nt"&gt;input&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt;
&lt;span class="nt"&gt;optgroup&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt;
&lt;span class="nt"&gt;select&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt;
&lt;span class="nt"&gt;textarea&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nl"&gt;font-family&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;inherit&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nc"&gt;.container&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nl"&gt;display&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;grid&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="py"&gt;grid-template-columns&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;200px&lt;/span&gt; &lt;span class="m"&gt;50px&lt;/span&gt; &lt;span class="m"&gt;50px&lt;/span&gt; &lt;span class="m"&gt;200px&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="py"&gt;grid-template-rows&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;auto&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="py"&gt;grid-template-areas&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;"header header header header"&lt;/span&gt; &lt;span class="s1"&gt;"type1 type1 type2 type2"&lt;/span&gt; &lt;span class="s1"&gt;". toggle toggle ."&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="py"&gt;row-gap&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;20px&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nc"&gt;.headerContainer&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="py"&gt;grid-area&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;header&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nc"&gt;.singleButtonType1&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="py"&gt;grid-area&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;type1&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nc"&gt;.singleButtonType2&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="py"&gt;grid-area&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;type2&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nc"&gt;.toggle&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="py"&gt;grid-area&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;toggle&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nc"&gt;.type1Button&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="c"&gt;/* So I can set a margin-bottom */&lt;/span&gt;
    &lt;span class="nl"&gt;display&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;inline-block&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="nl"&gt;padding&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;0.5em&lt;/span&gt; &lt;span class="m"&gt;1.5em&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="nl"&gt;border-radius&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;8px&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="nl"&gt;border&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;2px&lt;/span&gt; &lt;span class="nb"&gt;solid&lt;/span&gt; &lt;span class="no"&gt;black&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="nl"&gt;text-align&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;center&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="nl"&gt;font-weight&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;bold&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="nl"&gt;font-size&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;1em&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="nl"&gt;line-height&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;1.65em&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="nl"&gt;cursor&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;pointer&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="nl"&gt;color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="no"&gt;white&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="nl"&gt;background-color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="no"&gt;black&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="nl"&gt;margin-right&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;1rem&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="nl"&gt;margin-bottom&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;1rem&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nc"&gt;.type2Button&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="c"&gt;/* So I can set a margin-bottom */&lt;/span&gt;
    &lt;span class="nl"&gt;display&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;inline-block&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="nl"&gt;padding&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;0.5em&lt;/span&gt; &lt;span class="m"&gt;1.5em&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="nl"&gt;border-radius&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;8px&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="nl"&gt;border&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;2px&lt;/span&gt; &lt;span class="nb"&gt;solid&lt;/span&gt; &lt;span class="no"&gt;black&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="nl"&gt;text-align&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;center&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="nl"&gt;font-weight&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;bold&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="nl"&gt;font-size&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;1em&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="nl"&gt;line-height&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;1.65em&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="nl"&gt;cursor&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;pointer&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="nl"&gt;color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="no"&gt;black&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="nl"&gt;background-color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="no"&gt;white&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="nl"&gt;margin-right&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;1rem&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="nl"&gt;margin-bottom&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;1rem&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="c"&gt;/* 
.toggle {
    margin: auto;
} */&lt;/span&gt;

&lt;span class="nc"&gt;.toggleButton&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nl"&gt;padding&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;15px&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="nl"&gt;cursor&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;pointer&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="nl"&gt;background-color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="no"&gt;dimgray&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="nl"&gt;border-radius&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;5px&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="nl"&gt;border-color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="no"&gt;dimgray&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="nl"&gt;border&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;2px&lt;/span&gt; &lt;span class="no"&gt;dimgray&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="nl"&gt;font-size&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;large&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="nl"&gt;color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="no"&gt;black&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="nl"&gt;font-weight&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;bold&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This is basically done! We now have a proper wireframe we can refer to when building our app. You can follow the video for my entire thinking pattern, but if you're just up for the final result - now you have it:)&lt;/p&gt;

&lt;p&gt;Moving on - let's learn a little bit about React in our first (!) sidestep, before going head-first into building our application. If you've got React chops feel free to bypass the next 3 articles, and jump straight to article 10, which deals with Shopify's design system, Polaris.&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>shopify</category>
      <category>shopifyapps</category>
      <category>jamstack</category>
    </item>
    <item>
      <title>Shopify App From Scratch #5 - Mockup Part 1</title>
      <dc:creator>Red Cap Tom</dc:creator>
      <pubDate>Thu, 28 May 2020 22:26:33 +0000</pubDate>
      <link>https://forem.com/redcaptom/shopify-app-from-scratch-5-mockup-part-1-4303</link>
      <guid>https://forem.com/redcaptom/shopify-app-from-scratch-5-mockup-part-1-4303</guid>
      <description>&lt;h2&gt;
  
  
  Deprecation Notice
&lt;/h2&gt;

&lt;p&gt;Yeah, yeah, I know. I hate it too when people abandon tutorial series mid-way. But, due to (exciting!) circumstances, I'm calling it quits for now.&lt;/p&gt;

&lt;p&gt;I'm thinking of just dropping a link to the full repo here - it's a mess, but it's something you guys can chew on instead of my empty promises.&lt;/p&gt;

&lt;p&gt;If you'd like me to drop it here - let me know at &lt;a href="mailto:hey@redcaptom.com"&gt;hey@redcaptom.com&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;And, just sayin', I had a BLAST doing this. If you know something - anything - about technology, take the time to write it down as a tutorial series. You will get SO, SO much value out of it, you can't even believe it.&lt;/p&gt;

&lt;p&gt;Until we meet again - RCT :)&lt;/p&gt;

&lt;h2&gt;
  
  
  The Video (Scroll down for the article)
&lt;/h2&gt;

&lt;p&gt;Coming soon!&lt;/p&gt;

&lt;h2&gt;
  
  
  But I Don't Want To Draw Pictures, Tom...
&lt;/h2&gt;

&lt;p&gt;All right, so we talked about getting set up with the tooling, the tech that we're going to use, how to get ideas, how to verify them and all the other nice things that come along with starting a Shopify app project. I think we're ready to dive into the coding, but before we actually write any lines of code, I think it's important to understand what we're going to build. &lt;/p&gt;

&lt;p&gt;I, personally, never possessed the ability to actually jump right into the coding. I never could. I need to have some sort of visual aid to hold me responsible to the vision I wanted to build, or I make a mess of things. Really, really crappy spaghetti-unmaintainable-hellish-garbage code. The kind of code bad programmers - nay, bad &lt;em&gt;people&lt;/em&gt; - write. &lt;/p&gt;

&lt;p&gt;Solution? Mock it up! If I have a sketch of the screens in front of me in front-end projects (or a schema of the the flow in back-end projects) I tend to stay on track.&lt;/p&gt;

&lt;p&gt;In the video I actually walk through the mental path of what I want to have on the page, and then build it piece by piece. Since I don't think the process translates well to the written medium (read: I'm lazy and doing this transcription after recording the video) I will just say a few words and show you the final product.&lt;/p&gt;

&lt;p&gt;When thinking about a project, try to put yourself in the user's shoes. What buttons will they expect to see? Where on the page? What are they used to? What do they need to do? Remember that you are building a product for people who are intensely focused on creating more revenue and saving operations time. Is your app's value clear from the screens? Are they easy to understand, and easy to use? &lt;/p&gt;

&lt;p&gt;Spend some time thinking before coding. It's surprisingly useful, and can save you literally hours in follow-up fixes. 100% would recommend.  &lt;/p&gt;

&lt;p&gt;Anyways, here's a view of the final sketch: &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Flckxbhk0db1jswbsfoy1.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Flckxbhk0db1jswbsfoy1.png" alt="moqups-mockup"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Wiring It Up
&lt;/h2&gt;

&lt;p&gt;Having just a sketch is nice, but we will eventually need to output some sort of HTML to our users, right? JSX - the thing that we're going to actually output from our React app - is just HTML on steroids (which is actually a completely false statement from its implementation perspective, but we'll talk about that later).&lt;/p&gt;

&lt;p&gt;Anyways, to come closer to the final codeneeded, I like to wire things out in plain HTML. This gives me the barebones feel of a page before having to actually do all the styling logic, and allows me to catch any possible interface bugs (for example, wanting to put too many buttons in a row, which looks fine in my sketch but bad in the HTML wireframe).&lt;/p&gt;

&lt;p&gt;What I do, then, is create a preliminary sketch of how the HTML is going to look like, without any appended CSS. Here it is in all its glory:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fhrz9y36p8zkvksg5rsr4.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fhrz9y36p8zkvksg5rsr4.png" alt="base-html"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;And the final HTML:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;html&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;head&amp;gt;&lt;/span&gt;
        &lt;span class="nt"&gt;&amp;lt;title&amp;gt;&lt;/span&gt;
            Countries We Ship Button
        &lt;span class="nt"&gt;&amp;lt;/title&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;/head&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;body&amp;gt;&lt;/span&gt;
        &lt;span class="nt"&gt;&amp;lt;div&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"container"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
            &lt;span class="nt"&gt;&amp;lt;div&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"header"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
                &lt;span class="nt"&gt;&amp;lt;h1&amp;gt;&lt;/span&gt;Countries We Ship To Button&lt;span class="nt"&gt;&amp;lt;/h1&amp;gt;&lt;/span&gt;
            &lt;span class="nt"&gt;&amp;lt;/div&amp;gt;&lt;/span&gt;
            &lt;span class="nt"&gt;&amp;lt;div&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"prompt"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
                &lt;span class="nt"&gt;&amp;lt;p&amp;gt;&lt;/span&gt;Please select the type of button you'd like to create:&lt;span class="nt"&gt;&amp;lt;/p&amp;gt;&lt;/span&gt;
            &lt;span class="nt"&gt;&amp;lt;/div&amp;gt;&lt;/span&gt;
            &lt;span class="nt"&gt;&amp;lt;div&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"typeContainer"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
                &lt;span class="nt"&gt;&amp;lt;div&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"singleButtonType"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
                    &lt;span class="nt"&gt;&amp;lt;div&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"type1Example"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
                    &lt;span class="nt"&gt;&amp;lt;/div&amp;gt;&lt;/span&gt;
                    &lt;span class="nt"&gt;&amp;lt;input&lt;/span&gt; &lt;span class="na"&gt;type=&lt;/span&gt;&lt;span class="s"&gt;"checkbox"&lt;/span&gt; &lt;span class="na"&gt;value=&lt;/span&gt;&lt;span class="s"&gt;"type1"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;Type 1
                &lt;span class="nt"&gt;&amp;lt;/div&amp;gt;&lt;/span&gt;
                &lt;span class="nt"&gt;&amp;lt;div&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"singleButtonType"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
                    &lt;span class="nt"&gt;&amp;lt;div&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"type2Example"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
                    &lt;span class="nt"&gt;&amp;lt;/div&amp;gt;&lt;/span&gt;
                    &lt;span class="nt"&gt;&amp;lt;input&lt;/span&gt; &lt;span class="na"&gt;type=&lt;/span&gt;&lt;span class="s"&gt;"checkbox"&lt;/span&gt; &lt;span class="na"&gt;value=&lt;/span&gt;&lt;span class="s"&gt;"type2"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;Type 2
                &lt;span class="nt"&gt;&amp;lt;/div&amp;gt;&lt;/span&gt;
            &lt;span class="nt"&gt;&amp;lt;/div&amp;gt;&lt;/span&gt;
            &lt;span class="nt"&gt;&amp;lt;div&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"toggleButton"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
                &lt;span class="nt"&gt;&amp;lt;button&amp;gt;&lt;/span&gt;Toggle&lt;span class="nt"&gt;&amp;lt;/button&amp;gt;&lt;/span&gt;
            &lt;span class="nt"&gt;&amp;lt;/div&amp;gt;&lt;/span&gt;
        &lt;span class="nt"&gt;&amp;lt;/div&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;/body&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/html&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And now we have a basic HTML wireframe of our application's main page.&lt;/p&gt;

&lt;p&gt;In the next article, I'll deal with the CSS and making this resemble what the final, Polaris-based version will look like. In your own project, feel free to stop after this stage if you feel like you have enough inspiration to get coding!&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>shopify</category>
      <category>shopifyapps</category>
      <category>jamstack</category>
    </item>
    <item>
      <title>Shopify App From Scratch #4 - Tech Stack</title>
      <dc:creator>Red Cap Tom</dc:creator>
      <pubDate>Thu, 28 May 2020 20:45:34 +0000</pubDate>
      <link>https://forem.com/redcaptom/shopify-app-from-scratch-4-tech-stack-d2p</link>
      <guid>https://forem.com/redcaptom/shopify-app-from-scratch-4-tech-stack-d2p</guid>
      <description>&lt;h2&gt;
  
  
  Deprecation Notice
&lt;/h2&gt;

&lt;p&gt;Yeah, yeah, I know. I hate it too when people abandon tutorial series mid-way. But, due to (exciting!) circumstances, I'm calling it quits for now.&lt;/p&gt;

&lt;p&gt;I'm thinking of just dropping a link to the full repo here - it's a mess, but it's something you guys can chew on instead of my empty promises.&lt;/p&gt;

&lt;p&gt;If you'd like me to drop it here - let me know at &lt;a href="mailto:hey@redcaptom.com"&gt;hey@redcaptom.com&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;And, just sayin', I had a BLAST doing this. If you know something - anything - about technology, take the time to write it down as a tutorial series. You will get SO, SO much value out of it, you can't even believe it.&lt;/p&gt;

&lt;p&gt;Until we meet again - RCT :)&lt;/p&gt;

&lt;h2&gt;
  
  
  The Video (Scroll down for the article)
&lt;/h2&gt;

&lt;p&gt;Coming soon!&lt;/p&gt;

&lt;h2&gt;
  
  
  A Primer on the Origin of Shopify's Tech Stack
&lt;/h2&gt;

&lt;p&gt;Shopify, since its early days and still in essence (it appears), is a Ruby shop. If you're not from the RoR (Ruby on Rails) community, or have not been around for a long enough time, that might not be very obvious - but there are 3 main tells:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Tobi Lutcke's (Shopify's CEO and the dude who wrote the original Shopify code) &lt;a href="https://github.com/tobi" rel="noopener noreferrer"&gt;GitHub&lt;/a&gt; page is almost entirely Ruby:&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fotb9kbuplzhh61h5ql8x.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fotb9kbuplzhh61h5ql8x.png" alt="tobi-github-page"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;He was actually a &lt;a href="https://tobi.lutke.com/pages/about" rel="noopener noreferrer"&gt;RoR core team member&lt;/a&gt;, and a lot of the Shopify stuff used to revolve around that ecosystem.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;The &lt;a href="https://shopify.dev/tutorials" rel="noopener noreferrer"&gt;official Shopify App tutorials&lt;/a&gt; come in two main flavors - &lt;a href="https://shopify.dev/tutorials/build-a-shopify-app-with-node-and-react" rel="noopener noreferrer"&gt;JavaScript&lt;/a&gt; and &lt;a href="https://shopify.dev/tutorials/build-a-shopify-app-with-ruby-and-sinatra" rel="noopener noreferrer"&gt;Ruby&lt;/a&gt;.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;It &lt;a href="https://github.com/Shopify/shopify-app-cli/issues/277" rel="noopener noreferrer"&gt;used to be&lt;/a&gt; that you could only deploy from the &lt;a href="https://github.com/Shopify/shopify-app-cli" rel="noopener noreferrer"&gt;Shopify App CLI &lt;/a&gt;to Heroku - which is a big company today, but originated as a &lt;a href="https://en.wikipedia.org/wiki/Heroku#History" rel="noopener noreferrer"&gt;Ruby projects deployment tool&lt;/a&gt;. It seems that they have removed the option to deploy with the Shopify App CLI from the documentation since I wrote the article, however, which is a shame.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Why does this matter to you in 2020 (or maybe 2030? hopeful little me) reading this article? It goes to show that what we will be building in - JavaScript - only came into the game a bit later. This is indicative by some "rough edges" that remain in the development process for apps at the time of writing for the JS crowd. I &lt;em&gt;do not&lt;/em&gt; think that the JS dev process is harder than the Ruby dev process, but it's important to say the above out loud for when you get discouraged. There's constant movement by Shopify in this space - things that are hard today might be made obsolete tomorrow! Keep on pushing. :)&lt;/p&gt;

&lt;p&gt;Note: The aforementioned was added for the article and does not show up in the video. See? It's worth following the articles instead of the videos too!&lt;/p&gt;

&lt;h2&gt;
  
  
  The App We Will Be Building
&lt;/h2&gt;

&lt;p&gt;Moving on - if you follow the video, you notice that I make a small tangent around here to talk about the app we will be building from scratch - &lt;a href="https://apps.shopify.com/countries-we-ship-to" rel="noopener noreferrer"&gt;Countries We Ship To Button&lt;/a&gt;. Take a look at the video from the beginning and up until &lt;a href="https://youtu.be/zhCj-bDNto4?t=130" rel="noopener noreferrer"&gt;2:10&lt;/a&gt; to get an idea of what the application looks like in practice.&lt;/p&gt;

&lt;p&gt;I'm also namedropping quite a lot in the video, and doing so on purpose - the stack, when disassembled into its separate pieces, contains quite a few moving parts. But, in fact, what Shopify did was make a bunch of &lt;em&gt;smart&lt;/em&gt;, &lt;em&gt;sensible&lt;/em&gt; technological decisions for you. This might seem like a constraint on a first look, but it's really not - they're basically spilling the beans on what they use, and urge you to do the same.&lt;/p&gt;

&lt;p&gt;The next is simply a list of all those technologies, some links, and where they fit in our stack.&lt;/p&gt;

&lt;h3&gt;
  
  
  React - The front-end framework
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://reactjs.org/" rel="noopener noreferrer"&gt;React&lt;/a&gt; is one of the three major front-end JavaScript libraries (along with &lt;a href="https://vuejs.org/" rel="noopener noreferrer"&gt;Vue&lt;/a&gt; and &lt;a href="https://angular.io/" rel="noopener noreferrer"&gt;Angular&lt;/a&gt;). It is considered the largest player in this space today, and for good reason - while a bit complicated to grasp at first, it steps up your front-end game quite a bit.&lt;/p&gt;

&lt;p&gt;It takes a somewhat different approach to interface building than what you're probably used to from PHP or any server-rendered language: Instead of populating a of some source with information, it constructs the page piece-by-piece and reacts (get it?) to actions taken on the page to change the interface dynamically. That's weird if you're not used to it, but makes a lot of sense from the user's perspective - I click here, this loads in this part of the page, this is populated etc.&lt;/p&gt;

&lt;p&gt;It's like jQuery on steroids and without &lt;code&gt;$&lt;/code&gt;s all over the place.&lt;/p&gt;

&lt;p&gt;We will be using it to create this beautiful interface:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fhaw9p68l9ur5r6eqedz9.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fhaw9p68l9ur5r6eqedz9.png" alt="Countries We Ship To Button"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I will make a few videos detailing this part of the stack in detail, which should at least give you the ability to &lt;em&gt;read&lt;/em&gt; React code. If you don't have any React experience that's fine - you can fill the gaps as you go along - but I do recommend at least reading &lt;em&gt;some&lt;/em&gt; information about it, like the &lt;a href="https://reactjs.org/" rel="noopener noreferrer"&gt;official docs&lt;/a&gt; or Dave Ceddia's &lt;a href="https://daveceddia.com/pure-react/?utm_source=tom" rel="noopener noreferrer"&gt;Pure React&lt;/a&gt; (this is not an affiliate link, just a way for me and Dave to see who's coming from where).&lt;/p&gt;

&lt;p&gt;However, if you're already a JS person, spend very little time on catching up - I got you covered with some basics in the React sidestep. Stay tuned.&lt;/p&gt;

&lt;h3&gt;
  
  
  Next.js - The React Framework
&lt;/h3&gt;

&lt;p&gt;React, in and of itself, is lacking some basic utilities that can help you write code that is more performant (and, actually, help speed up &lt;em&gt;the coding process&lt;/em&gt; itself). For this purpose, &lt;a href="https://vercel.com/" rel="noopener noreferrer"&gt;Vercel&lt;/a&gt; (formerly Zeit) came up with &lt;a href="https://nextjs.org/" rel="noopener noreferrer"&gt;Next.js&lt;/a&gt; - the de-facto standard React framework.&lt;/p&gt;

&lt;p&gt;If you're not really into React it's kind of hard to understand how Next stacks up next to it, and what does it even offer. In our application, the main place you will encounter Next is in the custom server it creates at the start of &lt;code&gt;server.js&lt;/code&gt;. We will not really be using it all that much &lt;em&gt;in our code&lt;/em&gt;, just reaping the general benefits it produces on the side. I will elaborate more about that in the Next.js sidestep in this tutorial.&lt;/p&gt;

&lt;h3&gt;
  
  
  Polaris - The Shopify Design System
&lt;/h3&gt;

&lt;p&gt;Keep in mind that you will be building &lt;em&gt;inside&lt;/em&gt; the Shopify admin, meaning that your app should mimic the look and feel of the Shopify admin as much as possible. Knowing that this is not an easy fit, the Shopify people released &lt;a href="https://polaris.shopify.com/" rel="noopener noreferrer"&gt;Polaris&lt;/a&gt; - a design system that's intended to allow developers to get Shopify look and feel with little to no effort.&lt;/p&gt;

&lt;p&gt;Design systems, in most cases, are carefully-calculated interface languages, that are tuned to get a &lt;em&gt;feel&lt;/em&gt; across a screen. You can read about it some more &lt;a href="https://ux.shopify.com/think-like-a-chef-how-to-use-a-design-system-ae1f0e0e0dd7" rel="noopener noreferrer"&gt;here&lt;/a&gt;, but for now it's enough to say that Shopify provides React components that we can use in our apps. They have the same color, animations and general &lt;em&gt;feel&lt;/em&gt; as the Shopify admin's interface, which makes it relatively easy to create - inside your embedded apps - a familiar feeling for your merchants. I have a full side-step on this as well - stay tuned!&lt;/p&gt;

&lt;h3&gt;
  
  
  Node.js - JavaScript, Everywhere!
&lt;/h3&gt;

&lt;p&gt;Up until now, we talked about the front-end part of things - but there's a lot going on in the back-end as well! While we will code the front-end of the application first, the back-end is the real heavy lifter, and it's written entirely in &lt;a href="https://nodejs.org/en/" rel="noopener noreferrer"&gt;Node.js&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Saying that you write node code is a bit terminologically incorrect - it's like saying you're writing CLR instead of saying you're writing C# (which is not a great analogy, but the only one I could think of that is well-known enough to make sense). Node is a runtime - it is a way of running JavaScript on the server. What you're actually writing is JavaScript - much like you do on the front-end - except you do it on the backend, with the help of various tools and libraries that are designed for backend apps (like filesystem access, for example).&lt;/p&gt;

&lt;p&gt;The interesting bit about Node.js is that it's basically built around providing code as a service. What I mean by that is that it was originally built heavily around the concept of requests and responses, and propping up servers - see &lt;a href="https://nodejs.org/docs/latest-v13.x/api/synopsis.html" rel="noopener noreferrer"&gt;this example&lt;/a&gt; - as a main "course of action". This is a bit different than other backend programming languages that are more "general" in nature, and do not basically require you to prop up some server somewhere in your application.&lt;/p&gt;

&lt;p&gt;This is not true universally today, and Node is used everywhere in many different configurations, but for our purposes it's best to consider it as an &lt;em&gt;API writing language&lt;/em&gt;. We will be building a set of endpoints to be used by our front-end application, and those endpoints will perform various tasks that receive, modify and fetch information across our application and the Shopify servers. More about that in a future sidestep, though - for now, treat Node as JS on the server.&lt;/p&gt;

&lt;h3&gt;
  
  
  Koa - A Node.js Web Framework
&lt;/h3&gt;

&lt;p&gt;While you can totally write your servers in pure Node (and many do), it actually makes much more sense to use a proper web frameworks to run production-grade code. Those type of frameworks provide lots of utilities for you to perform common activities without having to re-write code from scratch - stuff like looking at the body of HTTP requests, handle specific types of HTTP headers, etc.&lt;/p&gt;

&lt;p&gt;Shopify recommends the use of &lt;a href="https://koajs.com/" rel="noopener noreferrer"&gt;Koa&lt;/a&gt;, which is a slimmer, more modern alternative to the "standard" Node.js web framework - &lt;a href="https://expressjs.com/" rel="noopener noreferrer"&gt;Experss&lt;/a&gt;. The beauty about Koa is that it comes "without batteries" - meaning that you only get the base functionality out of the box, and then need to append more and more layers as you see fit. This makes your code a bit more understandable (but also a bit longer), since all the components of the framework are explicitly mentioned in your &lt;code&gt;server.js&lt;/code&gt; file.&lt;/p&gt;

&lt;h3&gt;
  
  
  GraphQL - Query Language For Rest APIs
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://graphql.org/" rel="noopener noreferrer"&gt;GraphQL&lt;/a&gt; is a rather new, very cool runtime (and associated query language and conceptualization) that seems like a really weird idea at first glance. What it's basically saying is - let's make a new query language, that's not really like SQL (so is a bit harder to learn), and use that to query our APIs.&lt;/p&gt;

&lt;p&gt;A keen observer will note that most APIs wrap database / ORM calls anyways, right? An API is just a fancy way to prevent your users from performing SQL queries on your database themselves, isn't it? Why do we need all of this fancy, shiny new stuff?&lt;/p&gt;

&lt;p&gt;Well, letting your users run &lt;em&gt;raw&lt;/em&gt; SQL queries on your database is a &lt;strong&gt;very bad idea&lt;/strong&gt;. Let's get that out of the way first. Do. Not. Do it.&lt;/p&gt;

&lt;p&gt;Having said that, have a way to &lt;em&gt;query&lt;/em&gt;, rather than just &lt;em&gt;call&lt;/em&gt;, your APIs is kinda awesome. Imagine you have a need to get some data in your application, that requires information from two different API endpoints. Usually this means two API calls - one for the first resource, and another one for the second resource. Then, you'd have to parse the information from both of those endpoints and return that data to the main application.&lt;/p&gt;

&lt;p&gt;With GraphQL, you can instead perform a single query, that gets you the information that &lt;em&gt;both&lt;/em&gt; API endpoints provide in a &lt;em&gt;single&lt;/em&gt; API call (to the &lt;a href="https://graphql.org/learn/execution/#root-fields-resolvers" rel="noopener noreferrer"&gt;GraphQL query root&lt;/a&gt;). In this query, you can also query only the relevant data you need - mostly removing the need to do data massaging later in the process!&lt;/p&gt;

&lt;p&gt;We will not be using GraphQL in our specific application , but I will be making a sidestep for it anyways since it's really important.&lt;/p&gt;

&lt;h4&gt;
  
  
  Apollo - GraphQL Client
&lt;/h4&gt;

&lt;p&gt;The foremost implementation of GraphQL for JavaScript is &lt;a href="https://www.apollographql.com/" rel="noopener noreferrer"&gt;Apollo&lt;/a&gt;, which is simply a GraphQL client you can use from inside React. I will talk more about it later. For now - just think of it as a component you can drop into your app, and perform queries with.&lt;/p&gt;

&lt;h3&gt;
  
  
  Shopify Liquid
&lt;/h3&gt;

&lt;p&gt;While used very sparsely in this app (it's glory moment is integrating the button into the merchant's store, and that's about it), &lt;a href="https://www.shopify.com/partners/blog/115244038-an-overview-of-liquid-shopifys-templating-language" rel="noopener noreferrer"&gt;Liquid&lt;/a&gt; is the way one write Shopify sites. I will not be doing a full sidestep on it, because it's really out of scope for this series (that is already looking like it's going to be super long anyways). &lt;/p&gt;

&lt;p&gt;That about sums it up for the tool stack. Let's start planning our app!&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>shopify</category>
      <category>shopifyapps</category>
      <category>jamstack</category>
    </item>
    <item>
      <title>Shopify App From Scratch #3 - Tools</title>
      <dc:creator>Red Cap Tom</dc:creator>
      <pubDate>Mon, 25 May 2020 22:17:09 +0000</pubDate>
      <link>https://forem.com/redcaptom/shopify-app-from-scratch-3-tools-581a</link>
      <guid>https://forem.com/redcaptom/shopify-app-from-scratch-3-tools-581a</guid>
      <description>&lt;h2&gt;
  
  
  Deprecation Notice
&lt;/h2&gt;

&lt;p&gt;Yeah, yeah, I know. I hate it too when people abandon tutorial series mid-way. But, due to (exciting!) circumstances, I'm calling it quits for now.&lt;/p&gt;

&lt;p&gt;I'm thinking of just dropping a link to the full repo here - it's a mess, but it's something you guys can chew on instead of my empty promises.&lt;/p&gt;

&lt;p&gt;If you'd like me to drop it here - let me know at &lt;a href="mailto:hey@redcaptom.com"&gt;hey@redcaptom.com&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;And, just sayin', I had a BLAST doing this. If you know something - anything - about technology, take the time to write it down as a tutorial series. You will get SO, SO much value out of it, you can't even believe it.&lt;/p&gt;

&lt;p&gt;Until we meet again - RCT :)&lt;/p&gt;

&lt;h2&gt;
  
  
  The Video (Scroll down for the article)
&lt;/h2&gt;

&lt;p&gt;Coming soon!&lt;/p&gt;

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

&lt;p&gt;Tooling is a touchy subject for programmers - each and every one of us has his own permutation of programs, scripts, config files, keyboard shortcuts and whatnot that we use on a daily basis, and which we trust to the core. Even more specifically, each language has its own ecosystem of tools and best practices - and developers who are part of some ecosystem tend to gather around the same tooling.&lt;/p&gt;

&lt;p&gt;While I do not subscribe to the dogma of "this tool is best since ever", I do strongly feel that if a tool is generally acceptable in the community you work in, you should at least consider using it. If possible, consult with a long-time developer in the same ecosystem and get his views on wha'ts good and what's not. They've most likely been at the same junction that you are now at an earlier time, and have insights you could use.&lt;/p&gt;

&lt;p&gt;This also has the added benefit of exposing you to new paths of thinking that might've not been obvious before. An easy example is &lt;code&gt;ngrok&lt;/code&gt; - a tool I will talk about soon. Unless you have experience port-forwarding to expose your local machine to the outside world, you might not fully appreciate this tool. But, I can assure you, it's a pretty awesome piece of software that deals with a tricky bit of networking that is not obvious from first sight. It also sent me down a rabbithole of networking that I'm glad I went down, since it made me a much better dev afterwards. This shows another benefit of learning new tools - the exploration of new thought directions the tools throw you in, that benefit you professionally.&lt;/p&gt;

&lt;p&gt;I will caveat the preceding notion, however, by mentioning that tooling is just that - tooling. Don't let it overwhelm you or detract you from the nail in front of you - the problem might become easier to deal with using a great tool, but it will not solve itself. Lower your head over they keyboard and resume coding, please. :)&lt;/p&gt;

&lt;p&gt;Anyways, back to business.&lt;/p&gt;

&lt;h3&gt;
  
  
  Code Editor - VSCode
&lt;/h3&gt;

&lt;p&gt;I'm a big fan of &lt;a href="https://code.visualstudio.com/"&gt;Visual Studio Code&lt;/a&gt; for anything web-dev. I was a &lt;a href="https://www.sublimetext.com/"&gt;Sublime Text&lt;/a&gt; user for many years, and eventually got to work at a company that used VSCode and fell in love with it. If you're deep in the JavaScript ecosystem (and you soon will be, as Shopify apps are pretty much a full-stack JS endeavor), this editor is just feature-packed: Formatters, linters, syntax higlighters, smart snippets, auto-refactorings, test framework bindings and what have you. &lt;/p&gt;

&lt;p&gt;The way I set it up usually is one &lt;a href="https://code.visualstudio.com/docs/getstarted/settings"&gt;workspace&lt;/a&gt; per "mental zone" - one for writing these tutorials, one for client applications, one for testing and learning, etc. Since it's &lt;a href="https://code.visualstudio.com/docs/getstarted/userinterface#_side-by-side-editing"&gt;pane-based&lt;/a&gt;, you also have a great separation of concerns and can edit server-side and front-end code side-by-side. You will see in the next videos that I try to first build the front-end component, and then iterate on back-end parts from that front-facing component (and dual-pane editors are a great asset in that approach). &lt;/p&gt;

&lt;h3&gt;
  
  
  Terminal Multiplexer - &lt;code&gt;tmux&lt;/code&gt;
&lt;/h3&gt;

&lt;p&gt;You don't really need &lt;a href="https://github.com/tmux/tmux/wiki"&gt;&lt;code&gt;tmux&lt;/code&gt;&lt;/a&gt;. Nobody &lt;em&gt;really&lt;/em&gt; needs it if they're mostly working in the editor (as you guys will). But, whenever you &lt;em&gt;do&lt;/em&gt; find yourself in need of a terminal, there's nothing quite like it. It lets you construct a set of multiple terminal windows in the same operating system window, arrange them however you see fit and switch between them with a key binding (as well as naming them, have more than one set of windows in the same window and much, much more).&lt;/p&gt;

&lt;p&gt;In our flow, we will use 3-4 windows at any given time: One for &lt;code&gt;ngrok&lt;/code&gt;, one for our dev server running with &lt;code&gt;npm run dev&lt;/code&gt; (more about this later), one with the project's folder open to do &lt;code&gt;git add . &amp;amp;&amp;amp; git commit -m"some commit message" &amp;amp;&amp;amp; git push -u origin master&lt;/code&gt; (again, more on this later) and (optinally) one with a test project to run test commands in. &lt;code&gt;tmux&lt;/code&gt; is perfect for this - you can see all incoming requests in the &lt;code&gt;ngrok&lt;/code&gt; window, any error messages in the server dev window, commit and push after every fix in the project/git window and run sample commands in the optional test window.&lt;/p&gt;

&lt;p&gt;This is of course perfectly feasible with a regular terminal window (or a combination of a terminal window and the in-editor terminal), but to me the &lt;code&gt;tmux&lt;/code&gt; approach is much cleaner and fits on a single monitor to my left (and not my main monitor in front of me that I use my editor on).&lt;/p&gt;

&lt;p&gt;Note, however, that &lt;code&gt;tmux&lt;/code&gt; is strictly a Linux tool at the time of writing this article. If you're on a Mac - use &lt;a href="https://www.iterm2.com/"&gt;&lt;code&gt;iTerm2&lt;/code&gt;&lt;/a&gt;. On Windows - &lt;a href="https://conemu.github.io/"&gt;&lt;code&gt;ConEmu&lt;/code&gt;&lt;/a&gt; is a great choice.&lt;/p&gt;

&lt;p&gt;Don't get hung up on terminal multiplexers too much for now, though - you already have enough tools to ramp up on, leave this one for the very last (if at all).&lt;/p&gt;

&lt;h3&gt;
  
  
  Node version management - &lt;code&gt;nvm&lt;/code&gt;
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://nodejs.org/en/"&gt;&lt;code&gt;NodeJS&lt;/code&gt;&lt;/a&gt; is at the core of most of what we will be building here. Your build tools run on it, you will be writing code in it and use its default package manager &lt;a href="https://www.npmjs.com/"&gt;&lt;code&gt;npm&lt;/code&gt;&lt;/a&gt; extensively. There is an inherent problem with Node, though - its developers tend to create breaking changes between versions.&lt;/p&gt;

&lt;p&gt;This is not a problem per se - Node's developers chose to prioritize adding new features as the language progressed instead of maintaining backwards compatibility - i.e. making sure old code works with new versions. It becomes a problem once you rely (as we will) on multiple packages, created by different authors at different times &lt;em&gt;using diffferent versions of node&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;For the most part, let &lt;code&gt;npm&lt;/code&gt; do its thing and set you up with the correct packages for your node version and whatever it is you're currently working on. But - what happens when you revisit an old project in a year from now, or want to use code from an older project written by someone else?&lt;/p&gt;

&lt;p&gt;You'd need to have installed - on your machine - different versions of Node. Again, this in and of itself is not complicated - just download each version to a different folder, add the binary to the path and be done with it, right?&lt;/p&gt;

&lt;p&gt;Wrong. It's a shitshow. You'll think you are using version A, when instead you'll be using version B and then committing code to your repositories that is designed to use with version C. Let's just... not.&lt;/p&gt;

&lt;p&gt;Instead, you can use &lt;a href="https://github.com/nvm-sh/nvm"&gt;&lt;code&gt;nvm&lt;/code&gt;&lt;/a&gt; for Mac / Linux (or &lt;a href="https://github.com/coreybutler/nvm-windows"&gt;&lt;code&gt;nvm-windows&lt;/code&gt;&lt;/a&gt; for Windows). These are tools that download, switch and manage Node versions for you. You could easially install some version of node, then switch to it using &lt;code&gt;nvm use 12.16.3&lt;/code&gt; when you want to use Node 12.16.3.&lt;/p&gt;

&lt;p&gt;This way you don't actually have to deal with configuring different Node installations - the manager does it all for you. While this value might still not be clear to you, wait until you have to work with other people's older code. Fun to be had by all! :)&lt;/p&gt;

&lt;p&gt;Sidenote: This sounds scary, when I'm thinking about it a bit deeper. It's really not, though - this is a solved problem. Use the tools at hand, get used to them, and move on. Lots to do, lots to do!&lt;/p&gt;

&lt;h3&gt;
  
  
  Tunnels, oh tunnels - &lt;code&gt;ngrok&lt;/code&gt;
&lt;/h3&gt;

&lt;p&gt;A Shopify embedded app (like the one we are going to soon build) does not actually run on the Shopify servers. As such, it requires some place to be hosted in. We'll talk about deployments way, way later, but for now we'd like to have someplace to run our apps from, so they can be embedded in Shopify.&lt;/p&gt;

&lt;p&gt;Traditionally, you'd need to throw your code up on a server for that to happen, or use tricky network hacks to get your local computer to act as a world-facing server. This whole endeavor is not really fun for anyone when all you want is a URL that leads to your computer, and to the directory that you run your code in. Well, that's what &lt;a href="https://ngrok.com/"&gt;&lt;code&gt;ngrok&lt;/code&gt;&lt;/a&gt; is for.&lt;/p&gt;

&lt;p&gt;I could into the details of how &lt;code&gt;ngrok&lt;/code&gt; works, and dive into what tunnels are, what the hell introspection is and why should you care, but the honest (and lazy) answer is that it's out of scope for this article. If you'd like a follow up on that, hit me up here or on Twitter and I'll write up a longer post.&lt;/p&gt;

&lt;p&gt;For now, just know that whenever you'll run your code in one terminal window, you can also expose it to the world by running &lt;code&gt;ngrok&lt;/code&gt; in another terminal window. This will allow us to "mimic" a hosted app on our machine, and have that code run inside the Shopify Admin panel. More about this - later.&lt;/p&gt;

&lt;h3&gt;
  
  
  Shopify official stuff
&lt;/h3&gt;

&lt;p&gt;I go deeper into this in the video, but there's also a few pieces of tooling Shopify itself provides. I suggest you watch the video for the visual walkthrough I do there for the following items, but if you still want a readable version - here's a short one:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;a href="https://github.com/Shopify/shopify-app-cli"&gt;Shopify App CLI&lt;/a&gt; - This is a Shopify project that is intended to be used as a supplement tool for developing apps. It scaffolds, serves, deploys and generally holds your hand when building Shopify apps. I would say that you should wait before using it. Instead, first learn on how an app is built, what is holds in it, where are all the important bits and pieces go - and then use the CLI to scaffold your projects. &lt;/li&gt;
&lt;li&gt;
&lt;a href="https://www.shopify.com/partners"&gt;Shopify Partner Account&lt;/a&gt; - All Shopify app builders are considered Shopify Partners, and are entitled to some nice perks and a direct support line to Shopify, to solve any issues. After you sign up for the (free) account, you will get access to a nice dashboard to manage all your apps and stores. We will use it extensively in this tutorial, so stay tuned.&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://help.shopify.com/en/partners/dashboard/managing-stores/development-stores"&gt;Shopify Development Store&lt;/a&gt; - A Shopify Online Store costs 29 USD a month. Since we will be developing for Shopify, the platform offers us a way to skip that fee and have a live store at our disposal for testing purposes. We will use one of those extensively as well for testing our app with.
&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  A note about operating systems
&lt;/h3&gt;

&lt;p&gt;I am a Linux user. I have no bad things to say about Windows. I have no bad things to say about Mac OS. I have no bad things to say about BSD. I don't care what you use, as long as it fits you and works for you. Don't let anybody ever tell you that you would become a better dev by abandoning Windows for a unix-based operating system. It's bullshit. Some of the best devs I know are Microsoft hounds, slinging C# and .Net in a scale you would not believe. Dogma is for the weak - write code, be better, and discard all the noise.  &lt;/p&gt;

&lt;p&gt;Having said that, feel free tot talk to me about help in setting up stuff for your own operating system for the sake of this tutorial. If I can't solve it myself, I can most likely refer you to the correct resource. And if your problem is interesting, it might merit another DEV post! :)&lt;/p&gt;

</description>
      <category>shopify</category>
      <category>shopifyapps</category>
      <category>jamstack</category>
      <category>javascript</category>
    </item>
    <item>
      <title>Shopify App From Scratch #2 - Idea Generation</title>
      <dc:creator>Red Cap Tom</dc:creator>
      <pubDate>Sun, 24 May 2020 20:24:26 +0000</pubDate>
      <link>https://forem.com/redcaptom/shopify-app-from-scratch-2-idea-generation-2dn2</link>
      <guid>https://forem.com/redcaptom/shopify-app-from-scratch-2-idea-generation-2dn2</guid>
      <description>&lt;h2&gt;
  
  
  Deprecation Notice
&lt;/h2&gt;

&lt;p&gt;Yeah, yeah, I know. I hate it too when people abandon tutorial series mid-way. But, due to (exciting!) circumstances, I'm calling it quits for now.&lt;/p&gt;

&lt;p&gt;I'm thinking of just dropping a link to the full repo here - it's a mess, but it's something you guys can chew on instead of my empty promises.&lt;/p&gt;

&lt;p&gt;If you'd like me to drop it here - let me know at &lt;a href="mailto:hey@redcaptom.com"&gt;hey@redcaptom.com&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;And, just sayin', I had a BLAST doing this. If you know something - anything - about technology, take the time to write it down as a tutorial series. You will get SO, SO much value out of it, you can't even believe it.&lt;/p&gt;

&lt;p&gt;Until we meet again - RCT :)&lt;/p&gt;

&lt;h2&gt;
  
  
  The Video (Scroll down for the article)
&lt;/h2&gt;

&lt;p&gt;Coming soon!&lt;/p&gt;

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

&lt;p&gt;Before we dive into the technical parts of how to create an application, I wanted to walk you through the process I use when trying to generate Shopify app ideas. I knew Shopify was one of the bigger platforms out there, and that many people were building various external integrations for it - so the very first thing I did was heading over the to the &lt;a href="https://apps.shopify.com/"&gt;Shopify App Store&lt;/a&gt; to get some inspiration.&lt;/p&gt;

&lt;h2&gt;
  
  
  The Shopify App Store
&lt;/h2&gt;

&lt;p&gt;A good first thing to look out for is the &lt;em&gt;Staff Picks&lt;/em&gt; section - this will give you a quick peek into what's trending and can help you figure out what people are building (and how well are they doing, and how much money they are charging). While browsing the store, you'll notice there are a bunch of categories on the top left menu. If you're verifying your idea, and not looking for a new one, try to figure out where you will fit inside one of these categories. Remember that it's much easier to fill a hole in an existing category then to go out on your own and create a new category from scratch. It will also serve as competitor research - you'll see who's who in your niche and can gauge how hard it will be to carve your place on the podium.&lt;/p&gt;

&lt;p&gt;If you're generating an idea, like me, start clicking through stuff and see what is actually being built. Something you see happening often is a developer taking an external API and offering a "wrapper" in the form of an App. An example (not shown in the video) is &lt;a href="https://apps.shopify.com/google-express-integration"&gt;this app&lt;/a&gt;, which is basically what you'd expect from a Google Shopping / Ads client for Shopify - it wraps the correct API calls in a familiar Shopify App interface for the merchants, and offers some added functionality. That's an awesome approach that I really like, and if you have some cool API that you know about you should definitely consider then you're saying maybe Shopify merchants will be it will be useful. So if I merchants think about crafting or, you know, wrapping that API in some Shopify app and adding that other Shopify as there wasn't an extension.&lt;/p&gt;

&lt;p&gt;Alright, so you're inspired. Let's now go see what people are actually struggling with - maybe you can help them out?&lt;/p&gt;

&lt;h2&gt;
  
  
  Facebook
&lt;/h2&gt;

&lt;p&gt;To be honest, the store itself did not prove super useful for me - I did not want to copy an app by someone else, I wanted to create something out of a real need in the community. For that, I went into a bit of a Facebook Groups binge and ended up browsing extensively through &lt;a href="https://www.facebook.com/groups/shopifyforbeginners/"&gt;this group&lt;/a&gt;. There are a bunch of different groups on slightly different topics, but I would start with the dropshipping or newbies one (there are literally dozens of them) and start really listening to what people are talking about.&lt;/p&gt;

&lt;p&gt;My immediate goal was to find people who difficulties that no app was meeting at the moment. If you look at these types of groups, every some time a person would come up with a genuine question about a topic that apps are not addressing. Sometime it's an external integration, sometime it's a visual item they'd like added to the store, sometime it's just an annoying Shopify glitch they need to get over - in all of those cases you can come in for the win and scoop an awesome app idea.&lt;/p&gt;

&lt;p&gt;The nice thing about this platform is that it's akin to inserting yourself into the mind of the merchant, and trying to figure out what stings them. What they're struggling with on the daily, what they feel should be more accessible, or easier, or faster.&lt;/p&gt;

&lt;p&gt;Haven't found anything interesting here? We always have Reddit...&lt;/p&gt;

&lt;h2&gt;
  
  
  Reddit
&lt;/h2&gt;

&lt;p&gt;One way the &lt;a href="https://www.reddit.com/r/shopify/?f=flair_name%3A%22App%20Dev%22"&gt;Shopify subreddit&lt;/a&gt; (note that I've filtered by flair to get only app dev related threads) differs than the facebook groups mentioned above is that the discussions seem to be a bit more fruitful. It might have something to do with the fact that most people are practically anonymous, but the subreddit is much less spammy than the FB groups and has substantially better content, in my book.&lt;/p&gt;

&lt;p&gt;This is a great place to not only get ideas for new apps, but also to find co-conspirators for your app journey, beta testers, API help and whatever else you need that has to do with the Shopify ecosystem. It's truly a treasure trove of information and I try to use it on the daily.&lt;/p&gt;

&lt;p&gt;Having said that, I was always a forum kinda guy - I grew up on messaging boards with fancy HTML signatures and 57-page threads. As it turns out, Shopify has community forums as well.&lt;/p&gt;

&lt;h2&gt;
  
  
  Shopify Community
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://community.shopify.com/c/Shopify-Community/ct-p/en"&gt;Shopify Community&lt;/a&gt; has a bunch of different forums you can browse to get a whiff of all the different merchants experience on the daily, and unlike Facebook and Reddit it is very, very well organized. Specifically, the &lt;a href="https://community.shopify.com/c/Shopify-Apps/bd-p/shopify-apps"&gt;Shopify Apps Forum&lt;/a&gt; proved to be very useful for me.&lt;/p&gt;

&lt;p&gt;The posts on this forum split in the middle to "what is the best app for X" posts and "I built app Y" posts. This is not very useful, but here and then you find diamonds in the rough that make it worth it - in my case it was &lt;a href="https://community.shopify.com/c/Shopify-Apps/NEW-APP-Blog-Comment-Notifications-free-service-is-finally-here/m-p/190145"&gt;this thread&lt;/a&gt; announcing a new app for blog comments. The guy who built it posted the thread and disappeared somewhere around 2014. So what is this whole blog comments thing anyways?&lt;/p&gt;

&lt;p&gt;Say you have a blog on Shopify. It makes sense that you would like to be notified when a new comments is left on one of your posts. It turns out Shopify does not offer blog comment notification at all - there is no way to trigger an e-mail when you receive a new comment from the Shopify admin panel. I saw this and a light went on in my mind - that's exactly what no-code tools are built for: listening for something happening (a blog comment coming in) and triggering a series of events (in our case - an e-mail message).&lt;/p&gt;

&lt;p&gt;So I sat down and wrote a no-code tutorial on how to get blog comment notifications via e-mail (see my comments in the e-mail for the conversation, but the full version of the tutorial is &lt;a href="https://redcaptom.com/merchant-tutorials/blog-comment-notifications/"&gt;available here&lt;/a&gt;). Now, despite this not being an app, I'm still getting a bunch of comments and e-mails following this thread, that enable me to connect with merchants in a better way than ever before. It's pretty awesome that I get to have that connection with merchants, since they often tell me in person what are their troubles and needs, which leads to more apps or tutorials, which leads to more merchants... you get my point.&lt;/p&gt;

&lt;p&gt;You should spend your time helping people. &lt;strong&gt;Be of service.&lt;/strong&gt; If you take a single key point away from this whole series is this point - be useful to the merchants. They need you to show them the nooks and crannies of the platform, and they are willing to put good money for good apps and resources. Just solve an actual need, and you'll be surprised how fast conversations will start with merchants.&lt;/p&gt;

&lt;p&gt;Just generate conversations, try to become part of the community and be helpful before you start something. Don't be that guy that posts links to their stuff but doesn't provide any value whatsoever.&lt;/p&gt;

&lt;h2&gt;
  
  
  What will we be building, then?
&lt;/h2&gt;

&lt;p&gt;Took me a while until I found something that was interesting - but after a daily routine of visiting the forums, answering things helpfully and looking around I finally settled on building an app based on &lt;a href="https://community.shopify.com/c/Shopify-Apps/App-to-show-which-countries-we-ship-to/td-p/617328"&gt;this thread&lt;/a&gt;. It's a simple concept - a button, placed somewhere on your site, that mentions which countries you ship to and which you don't. That should prevent people from ordering products from the store if the store does not ship to their country, preventing undesired orders from coming in.&lt;/p&gt;

&lt;p&gt;This looks kind of simple, right? It's a button, that gets some information about the shipping areas of the store, and shows up nicely with a pop-up message. It turns out, though, that just getting this up and running is a bit of a challenge if you don't know all the players involved. There's quite a bit going on in the back - getting the app reviewed, authentication to the store, API calls that fail weirdly, responsiveness across various stores... a lot of moving parts.&lt;/p&gt;

&lt;p&gt;So I started small - built a working version in HTML, CSS &amp;amp; JS. Then started working on the React/Polaris interface. Then wrote the backend API routes, and called them from the front-end, and added a bunch of niceties along the way to make it nicer for me to maintain. And from there I just iterated until I figured out how the app should look like, after talking to people and listening to what they needed and wanted.&lt;/p&gt;

&lt;p&gt;And if you take anything out of the tutorial series, let it be this - conversations with people, helping them for nothing in return, being of service and being of use is the best thing you can do for yourself. Be very responsive. Talk to people as much as possible. Be very forthcoming and honest. Dive in - I think when you look at it like this, it makes everything much more fun. :)&lt;/p&gt;

</description>
      <category>shopify</category>
      <category>shopifyapps</category>
      <category>jamstack</category>
      <category>javascript</category>
    </item>
    <item>
      <title>Shopify App From Scratch #1 - Introduction</title>
      <dc:creator>Red Cap Tom</dc:creator>
      <pubDate>Sun, 24 May 2020 20:22:03 +0000</pubDate>
      <link>https://forem.com/redcaptom/shopify-app-from-scratch-1-introduction-ek5</link>
      <guid>https://forem.com/redcaptom/shopify-app-from-scratch-1-introduction-ek5</guid>
      <description>&lt;h2&gt;
  
  
  Deprecation Notice
&lt;/h2&gt;

&lt;p&gt;Yeah, yeah, I know. I hate it too when people abandon tutorial series mid-way. But, due to (exciting!) circumstances, I'm calling it quits for now.&lt;/p&gt;

&lt;p&gt;I'm thinking of just dropping a link to the full repo here - it's a mess, but it's something you guys can chew on instead of my empty promises.&lt;/p&gt;

&lt;p&gt;If you'd like me to drop it here - let me know at &lt;a href="mailto:hey@redcaptom.com"&gt;hey@redcaptom.com&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;And, just sayin', I had a BLAST doing this. If you know something - anything - about technology, take the time to write it down as a tutorial series. You will get SO, SO much value out of it, you can't even believe it.&lt;/p&gt;

&lt;p&gt;Until we meet again - RCT :)&lt;/p&gt;

&lt;h2&gt;
  
  
  The Video (Scroll down for the article)
&lt;/h2&gt;

&lt;p&gt;Coming soon!&lt;/p&gt;

&lt;h2&gt;
  
  
  What now?
&lt;/h2&gt;

&lt;p&gt;So, in December of 2019 I set out to build a &lt;a href="https://shopify.com/"&gt;Shopify&lt;/a&gt; app.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--CYBVZbEc--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/vd1r1exaj05sqwnynqoe.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--CYBVZbEc--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/vd1r1exaj05sqwnynqoe.png" alt="Shopify Logo"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://shopify.com/"&gt;Shopify&lt;/a&gt; is an e-commerce platform that is, by far, the largest and most advanced one in the market. While I'm totally a fanboy, I can actually back that up by looking around - everyone and their brother is opening up a Shopify store. They offer solutions for payments, for shipping, for store design and whatever else you might be interested in as a business owner in need of an online presence.&lt;/p&gt;

&lt;h2&gt;
  
  
  The Shopify App Store
&lt;/h2&gt;

&lt;p&gt;At some point, Shopify figured out that they need an &lt;a href="https://apps.shopify.com/"&gt;App Store&lt;/a&gt; - a central location to allow third party developers to create merchant-tailored experiences in various niches. Shopify will provide developers with the tooling, the documentation and an 80% cut of every app installation - and the developers will come.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--3INbIgoU--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/vnyl27a6n7fgcnar19tt.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--3INbIgoU--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/vnyl27a6n7fgcnar19tt.png" alt="Shopify App Store"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;And come they did - 3,200 apps later, it looks like a win for Shopify. And to be frank, I see why from a developer's perspective - you get the means to build a money-making thing, with first-class support to boot. Not a a bad deal.&lt;/p&gt;

&lt;h2&gt;
  
  
  The Shopify App development experience
&lt;/h2&gt;

&lt;p&gt;However, even if you've got some notches in your developer belt, you might hit some bumps along the road. If, for example, you come from only frontend or only backend work you might find yourself struggling through their tutorials. Heck, I've hit my fair share just trying to make sense of the architecture decisions they made, so I can follow best practices of each platform as I'm building my app.&lt;/p&gt;

&lt;p&gt;So, having went through the experience myself, I can tell you that there are plenty of resources for learning the technologies involved and a (somewhat) active ecosystem around Shopify Apps. The problem begins when you're trying to connect all the parts together - to me, the &lt;a href="https://shopify.dev/tutorials/build-a-shopify-app-with-node-and-react"&gt;official tutorial&lt;/a&gt; is a bit lacking in basic concept explanations. I know, I know, it's out of scope for Shopify to explain "external" things - like what a &lt;a href="https://nextjs.org/docs/advanced-features/custom-server"&gt;custom Next.js server&lt;/a&gt; is, or how is &lt;a href="https://koajs.com/"&gt;Koa&lt;/a&gt; different from &lt;a href="https://expressjs.com/"&gt;Express&lt;/a&gt; and why they chose to use it over Express, or how to deploy your app to &lt;a href="https://www.heroku.com/"&gt;Heroku&lt;/a&gt; in a way that keeps you sane and asleep at night, or... you get the picture.&lt;/p&gt;

&lt;p&gt;Wait, that sounds like an awesome opportunity to make a mark in the tutorial space, isn't it? Well, this is the reasoning behind what you're reading right now. I want to make this the resource I wished I had when I started working on my app.&lt;/p&gt;

&lt;h2&gt;
  
  
  This tutorial series
&lt;/h2&gt;

&lt;p&gt;In practice, what I'm trying to achieve in this tutorial series is a full walkthrough of what it's like to develop a Shopify App - the thought process, the tools and the nitty-gritty details that no one is talking about in the official resources. I will walk you through from setting up your machine for work, getting an app idea (or verifying an existing one) all the way to deploying your app and (most likely) the marketing aspects you have in front of you.&lt;/p&gt;

&lt;p&gt;You'll see that I prefer to dwell on some things and skip others. Generally speaking, I will elaborate on non-Shopify things in what I call &lt;strong&gt;sidesteps&lt;/strong&gt;, which are mini-deep-dives for the uninitiated. I will do those for React, for Koa, for Next.js and other goodies you need to know &lt;em&gt;just enough&lt;/em&gt; of to get along.&lt;/p&gt;

&lt;p&gt;This will make for a rather long tutorial series - I assume it will be around 60-70 videos when I'm done (ambitious me!), each one between 5-45 minutes, depending on the subject. Wherever possible I'd make an attempt to stick to 10-ish minute videos, because I too cannot stand never-ending series, but bare with me if I'm going over budget here and there.&lt;/p&gt;

&lt;h2&gt;
  
  
  About going off the path
&lt;/h2&gt;

&lt;p&gt;I'm posting this series because I wanted to have one like, it and couldn't find one. I might at some point decide that I'd like to take it in some direction that tangents from the original path.&lt;/p&gt;

&lt;p&gt;If you're following my work and would like me to take some time to explain something that I haven't covered - just ping me at &lt;a href="//mailto:hey@redcaptom.com"&gt;hey@redcaptom.com&lt;/a&gt;. I'll find the time and make a video, if possible, and I assume that if you're struggling with this you're note alone.&lt;/p&gt;

&lt;p&gt;Now, let's do this!&lt;/p&gt;

</description>
      <category>shopify</category>
      <category>shopifyapps</category>
      <category>jamstack</category>
      <category>javascript</category>
    </item>
  </channel>
</rss>
