<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Stef Cola</title>
    <description>The latest articles on DEV Community by Stef Cola (@stefdotninja).</description>
    <link>https://dev.to/stefdotninja</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%2F24973%2Fd0000b6a-7aed-4756-a298-860d61c0cf64.jpg</url>
      <title>DEV Community: Stef Cola</title>
      <link>https://dev.to/stefdotninja</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/stefdotninja"/>
    <language>en</language>
    <item>
      <title>Learning React - Week 4</title>
      <dc:creator>Stef Cola</dc:creator>
      <pubDate>Thu, 03 Aug 2017 04:30:28 +0000</pubDate>
      <link>https://dev.to/stefdotninja/learning-react---week-4</link>
      <guid>https://dev.to/stefdotninja/learning-react---week-4</guid>
      <description>&lt;p&gt;This article originally appeared on &lt;a href="https://stef.ninja/learning-react-week-4/" rel="noopener noreferrer"&gt;stef.ninja&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;This is the final post in my &lt;a href="https://dev.to/tamrrat/blogging-driven-learning"&gt;blogging driven learning&lt;/a&gt; exploration of &lt;a href="https://facebook.github.io/react/" rel="noopener noreferrer"&gt;React&lt;/a&gt;. I have been working through the &lt;a href="https://reactforbeginners.com/" rel="noopener noreferrer"&gt;React for Beginners&lt;/a&gt; course from &lt;a href="https://twitter.com/wesbos" rel="noopener noreferrer"&gt;Wes Bos&lt;/a&gt; and documenting my takeaways from each lesson. &lt;/p&gt;

&lt;p&gt;This is an &lt;strong&gt;AWESOME&lt;/strong&gt; course and I highly recommend it to anyone looking to learn React.&lt;/p&gt;

&lt;p&gt;You can find more notes in &lt;a href="https://dev.to/learning-react-week-1/"&gt;Week 1&lt;/a&gt;, &lt;a href="https://dev.to/learning-react-week-2/"&gt;Week 2&lt;/a&gt; and &lt;a href="https://dev.to/learning-react-week-3/"&gt;Week 3&lt;/a&gt; of the series.&lt;/p&gt;




&lt;h3&gt;
  
  
  Day 22: Animating React Components
&lt;/h3&gt;

&lt;p&gt;Animations are a fun way to inject movement into our webpage. This can be done via the traditional method of css (like the GIF below) or some more interactive React animations that we will explore further.&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%2Fs3-ap-southeast-2.amazonaws.com%2Fghost-blog-stef-ninja%2F2017%2F07%2Fcss_animation-1500949974188.gif" 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%2Fs3-ap-southeast-2.amazonaws.com%2Fghost-blog-stef-ninja%2F2017%2F07%2Fcss_animation-1500949974188.gif" alt="CSS Animation"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h6&gt;
  
  
  NPM Scripts &amp;amp; CSS Preprocessors
&lt;/h6&gt;

&lt;p&gt;Today's lesson touched on a few new concepts including the use of &lt;a href="https://github.com/tj/styl" rel="noopener noreferrer"&gt;styl&lt;/a&gt; as a CSS preprocessor. We also explored how this can be integrated in the npm scripts to enable hot reloading during development.&lt;/p&gt;

&lt;p&gt;Using the npm scripts in the &lt;code&gt;package.json&lt;/code&gt; we are able to call &lt;code&gt;$ npm run watch&lt;/code&gt; in the terminal. It will then concurrently run &lt;code&gt;start&lt;/code&gt; &amp;amp; &lt;code&gt;styles:watch&lt;/code&gt;. Then if one of them breaks it's going to kill the other one and show an error in the terminal. This makes development really easy.&lt;/p&gt;

&lt;p&gt;This is what the npm scripts look like at this point:&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%2Fs3-ap-southeast-2.amazonaws.com%2Fghost-blog-stef-ninja%2F2017%2F07%2Fwebpack_scripts-1500949986757.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%2Fs3-ap-southeast-2.amazonaws.com%2Fghost-blog-stef-ninja%2F2017%2F07%2Fwebpack_scripts-1500949986757.png" alt="npm scripts"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Note: In our development environment at work we don't use external CSS or CSS preprocessors as we have opted for &lt;a href="https://github.com/styled-components/styled-components" rel="noopener noreferrer"&gt;styled components&lt;/a&gt; (I talked more about this in &lt;a href="https://stef.ninja/learning-react-week-1/" rel="noopener noreferrer"&gt;Day 4&lt;/a&gt;).&lt;/p&gt;

&lt;h6&gt;
  
  
  Animations
&lt;/h6&gt;

&lt;p&gt;Now that we have our styling options sorted out we can get into the meat of animating React Components.&lt;/p&gt;

&lt;p&gt;Our aim today is to animate our order with some subtle movements:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;When a new fish is added to the order it should animate in.&lt;/li&gt;
&lt;li&gt;When a fish is removed from an order is should animate out.&lt;/li&gt;
&lt;li&gt;When the number of lbs of a fish increases the number should animate up.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;These are only small movements and we will do a lot of work to make them happen but the polished finish that they give the website is a nice touch.&lt;/p&gt;

&lt;p&gt;The first step we need to do is open up our HTML to include classes that we can hook into for our animations. You can do this using the CSSTransitionGroup.&lt;/p&gt;

&lt;p&gt;We modified the &lt;code&gt;ul&lt;/code&gt; component to be a &lt;code&gt;CSSTransitionGroup&lt;/code&gt; component instead. This looks like this in the code:&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%2Fs3-ap-southeast-2.amazonaws.com%2Fghost-blog-stef-ninja%2F2017%2F07%2Fcsstransitiongroup-1500950054510.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%2Fs3-ap-southeast-2.amazonaws.com%2Fghost-blog-stef-ninja%2F2017%2F07%2Fcsstransitiongroup-1500950054510.png" alt="CSSTransitionGroup"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Note: By adding the &lt;code&gt;component="ul"&lt;/code&gt; this tells React that we want the component to render a unordered list component in HTML but maintain it as a ReactCSSTransitionGroup in React.&lt;/p&gt;

&lt;p&gt;The additional attributes on the &lt;code&gt;CSSTransitionGroup&lt;/code&gt; component control temporary classes on the &lt;code&gt;ul&lt;/code&gt; HTML component. You can see how these classes display via the developer tools:&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%2Fs3-ap-southeast-2.amazonaws.com%2Fghost-blog-stef-ninja%2F2017%2F07%2FCSSTransitionGroup-1500950070552.gif" 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%2Fs3-ap-southeast-2.amazonaws.com%2Fghost-blog-stef-ninja%2F2017%2F07%2FCSSTransitionGroup-1500950070552.gif" alt="Temporary classes rendered by the CSSTransitionGroup"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;These temporary classes can then be hooked into via CSS. We are able to use &lt;a href="https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Transitions/Using_CSS_transitions" rel="noopener noreferrer"&gt;CSS Transitions&lt;/a&gt; because there is an initial state (class &lt;code&gt;order-enter&lt;/code&gt;/&lt;code&gt;order-leave&lt;/code&gt;) and a final state (class &lt;code&gt;order-enter-active&lt;/code&gt;/&lt;code&gt;order-leave-active&lt;/code&gt;) that we can reference.&lt;/p&gt;

&lt;p&gt;These can then be styled like 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%2Fs3-ap-southeast-2.amazonaws.com%2Fghost-blog-stef-ninja%2F2017%2F07%2Fstyles-1500950094516.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%2Fs3-ap-southeast-2.amazonaws.com%2Fghost-blog-stef-ninja%2F2017%2F07%2Fstyles-1500950094516.png" alt="Styles"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Note: the lack of &lt;code&gt;{}, : or ;&lt;/code&gt; in the &lt;code&gt;.styl&lt;/code&gt; documents&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;This renders out animations that look great:&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%2Fs3-ap-southeast-2.amazonaws.com%2Fghost-blog-stef-ninja%2F2017%2F07%2Fanimations_first_step-1500950104227.gif" 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%2Fs3-ap-southeast-2.amazonaws.com%2Fghost-blog-stef-ninja%2F2017%2F07%2Fanimations_first_step-1500950104227.gif" alt="Animations first step"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The final task in todays lesson is to animate the count of the lbs for each fish in the order. The animation that we are aiming for looks like the previous number is being pushed out by the new number. This requires a duplication of the element that will let us animate the 'old' version of the element out whilst simultaniously animating the 'new' version of the element in.&lt;/p&gt;

&lt;p&gt;This animation style requires us to duplicate the &lt;code&gt;{count}&lt;/code&gt; span. To do this we will add a &lt;code&gt;key&lt;/code&gt; attribute with the value &lt;code&gt;{count}&lt;/code&gt; as well as wrap the &lt;code&gt;{count}&lt;/code&gt; in a &lt;code&gt;CSSTransitionGroup&lt;/code&gt; and additional &lt;code&gt;span&lt;/code&gt;. The code looks like 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%2Fs3-ap-southeast-2.amazonaws.com%2Fghost-blog-stef-ninja%2F2017%2F07%2Fcount_span-1500950117834.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%2Fs3-ap-southeast-2.amazonaws.com%2Fghost-blog-stef-ninja%2F2017%2F07%2Fcount_span-1500950117834.png" alt="Count code"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This results in two spans being created - a new one with an updated &lt;code&gt;{count}&lt;/code&gt; and a &lt;code&gt;order-enter-active&lt;/code&gt; class and the original &lt;code&gt;{count}&lt;/code&gt; that now has a &lt;code&gt;order-leave-active&lt;/code&gt; class on it.&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%2Fs3-ap-southeast-2.amazonaws.com%2Fghost-blog-stef-ninja%2F2017%2F07%2Fcount_csstransitiongroup-1500950133063.gif" 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%2Fs3-ap-southeast-2.amazonaws.com%2Fghost-blog-stef-ninja%2F2017%2F07%2Fcount_csstransitiongroup-1500950133063.gif" alt="Count CSSTransitionGroup in Action"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now all that is left is to add the animation styles in:&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%2Fs3-ap-southeast-2.amazonaws.com%2Fghost-blog-stef-ninja%2F2017%2F07%2Fcount_animation_styles-1500950148468.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%2Fs3-ap-southeast-2.amazonaws.com%2Fghost-blog-stef-ninja%2F2017%2F07%2Fcount_animation_styles-1500950148468.png" alt="Count Animation styles"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h6&gt;
  
  
  To Do:
&lt;/h6&gt;

&lt;ul&gt;
&lt;li&gt;Import CssTransitionGroup from 'react-addons-css-transition-group' into &lt;code&gt;Order.js&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Modify the &lt;code&gt;ul&lt;/code&gt; to be a &lt;code&gt;CSSTransitionGroup&lt;/code&gt; &amp;amp; add the required attributes.&lt;/li&gt;
&lt;li&gt;Modify the &lt;code&gt;{count}&lt;/code&gt; to be wrapped in a &lt;code&gt;CSSTransitionGroup&lt;/code&gt; &amp;amp; set the attribute &lt;code&gt;key&lt;/code&gt; to &lt;code&gt;{count}&lt;/code&gt; (so we have a unique reference available).&lt;/li&gt;
&lt;li&gt;Add animation using CSS transitions in the &lt;code&gt;_animations.styl&lt;/code&gt; document.&lt;/li&gt;
&lt;/ul&gt;

&lt;h6&gt;
  
  
  Today the app looks like:
&lt;/h6&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%2Fs3-ap-southeast-2.amazonaws.com%2Fghost-blog-stef-ninja%2F2017%2F07%2Fday22_animations-1500950157836.gif" 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%2Fs3-ap-southeast-2.amazonaws.com%2Fghost-blog-stef-ninja%2F2017%2F07%2Fday22_animations-1500950157836.gif" alt="App on Day 22 of the React for Beginners Course"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;[Video 22: Animating React Components]&lt;/em&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Day 23: PropTypes for the Win
&lt;/h3&gt;

&lt;p&gt;What are PropTypes? They are validators that make sure the data coming into a component is valid. &lt;/p&gt;

&lt;p&gt;Today's lesson covered inserting PropType validations into every component of the app. We used the &lt;code&gt;React.PropType&lt;/code&gt; to do this which you can read more about &lt;a href="https://facebook.github.io/react/docs/typechecking-with-proptypes.html" rel="noopener noreferrer"&gt;here&lt;/a&gt;. &lt;/p&gt;

&lt;p&gt;As of React v15.5 we should be using the &lt;code&gt;prop-types&lt;/code&gt; library instead of the &lt;code&gt;React.PropTypes&lt;/code&gt;. This moves away from accessing &lt;code&gt;PropTypes&lt;/code&gt; from the main &lt;code&gt;React&lt;/code&gt; object which seems to be a common move in React v15.5. Read more about &lt;a href="https://facebook.github.io/react/blog/2017/04/07/react-v15.5.0.html#migrating-from-react.proptypes" rel="noopener noreferrer"&gt;migrating from React.PropTypes here&lt;/a&gt;.&lt;/p&gt;

&lt;h6&gt;
  
  
  To Do:
&lt;/h6&gt;

&lt;ul&gt;
&lt;li&gt;Add proptype validators to all components.&lt;/li&gt;
&lt;/ul&gt;

&lt;h6&gt;
  
  
  Today the app looks like:
&lt;/h6&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%2Fs3-ap-southeast-2.amazonaws.com%2Fghost-blog-stef-ninja%2F2017%2F07%2Fday23-1501456288496.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%2Fs3-ap-southeast-2.amazonaws.com%2Fghost-blog-stef-ninja%2F2017%2F07%2Fday23-1501456288496.png" alt="App on Day 23 of the React for Beginners Course"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Note: There is no visual changes that were made in today's lesson.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;[Video 23: Component Validation with PropTypes]&lt;/em&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Day 24: Authentication with Firebase
&lt;/h3&gt;

&lt;p&gt;Currently the database and state can be edited by all visitors. This level of authentication and security is too low for a production level app so we really need to reign that back in.&lt;/p&gt;

&lt;p&gt;To do this we will create an application that requires you to login with GitHub, Facebook or Twitter before you can edit the Inventory of a store. The first person to login to that store will be saved as the owner of that store (not a super practical realworld workflow but good enough for todays purposes). This authentication is all going to be completed client side with the backend being handled by Firebase.&lt;/p&gt;

&lt;p&gt;All of the sensitive API Secrets and Client IDs are going directly into Firebase rather than our client facing app. This adds a level of security that we don't even need to think about.&lt;/p&gt;

&lt;h6&gt;
  
  
  Login Authentication with Firebase
&lt;/h6&gt;

&lt;p&gt;Wes makes this look super simple. He follows these steps:&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;Create a Facebook App with Facebook Login.&lt;/li&gt;
  &lt;li&gt;Create a `Sign-in Method` with Facebook enabled on Firebase.&lt;/li&gt;
  &lt;li&gt;Copy the `OAuth redirection URI` from the Firebase tab into the Facebook App settings.&lt;/li&gt;
  &lt;li&gt;Enable `Embedded Browser OAuth Login` in the Facebook App settings. Save the changes.&lt;/li&gt;
  &lt;li&gt;Copy the `App ID` and `App Secret` into the Firebase Facebook authentication settings.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;You can do a similar process for all of the Sign-in Providers (Email/Password, Google, &lt;a href="https://developers.facebook.com/apps" rel="noopener noreferrer"&gt;Facebook&lt;/a&gt;, &lt;a href="https://apps.twitter.com" rel="noopener noreferrer"&gt;Twitter&lt;/a&gt;, &lt;a href="https://github.com/settings/applications/new" rel="noopener noreferrer"&gt;GitHub&lt;/a&gt;).&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Connecting to Firebase&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Connecting to Firebase is super simple with the Rebase package that we imported. We simply need to &lt;code&gt;Import base from '../base';&lt;/code&gt; at the top of our component and we can now connect to Firebase.&lt;/p&gt;

&lt;p&gt;It appears that this lesson covers an outdated method of connecting to Firebase.com. The new Firebase console and 3.x SDKs ask for a diferent method. I will explore connecting to Firebase.com using the method that Wes uses and then also the new and updated method. I will need to research how 'Rebase' works with the new vs old method. You can read more about &lt;a href="https://firebase.google.com/support/guides/firebase-web" rel="noopener noreferrer"&gt;Upgrading your Web / Node.js app from Firebase.com&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;The Firebase.com method of Authentication via OAuth is:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;ref.authWithOAuthPopup("twitter", function(error, authData) {
  if (error) {
    // An error occurred
    console.error(error);
  } else {
    // User signed in!
    var uid = authData.uid;
  }
});
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This can be compared to the new Firebase Authentication functionality that lives behind the &lt;code&gt;firebase.auth()&lt;/code&gt; service. There have been heaps of methods that have been renamed in this transition and the way that you authenticate users with OAuth is one of those:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;var auth = firebase.auth();

var provider = new firebase.auth.TwitterAuthProvider();
auth.signInWithPopup(provider).then(function(result) {
  // User signed in!
  var uid = result.user.uid;
}).catch(function(error) {
  // An error occurred
});
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Securing Firebase&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Earlier in our lessons we opened the security rules of our Firebase database right up. This was to help with ease of development. Now that we are nearing production release we need to close these right down.  Wes provided sample rules for this in &lt;code&gt;security-rules.json&lt;/code&gt;:&lt;/p&gt;

&lt;p&gt;These rules don't allow people who know the syntax of Firebase to edit it in a destructive manner. So the first rule doesn't allow anyone to delete currently existing data but allows all data to be read. The second rule only allows the store owner to edit data that already exists.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;{
  "rules": {
    // won't let people delete an existing room
    ".write": "!data.exists()",
    ".read": true,
    "$room" : {
      // only the store owner can edit the data
      ".write" : "auth != null &amp;amp;&amp;amp; (!data.exists() || data.child('owner').val() === auth.uid)",
      ".read" : true
      }
  }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h6&gt;
  
  
  To Do:
&lt;/h6&gt;

&lt;ul&gt;
&lt;li&gt;Create GitHub, Twitter &amp;amp; Facebook sign up methods in the &lt;code&gt;Auth&lt;/code&gt; section of Firebase.&lt;/li&gt;
&lt;li&gt;Create a method to render out the login buttons in the &lt;code&gt;Inventory&lt;/code&gt; component.&lt;/li&gt;
&lt;li&gt;Put a conditional statement into the &lt;code&gt;Inventory&lt;/code&gt; render method.

&lt;ul&gt;
&lt;li&gt;Check if the user is logged in. If not, return the &lt;code&gt;renderLogin&lt;/code&gt; method.&lt;/li&gt;
&lt;li&gt;Check if they're the owner of the current store. If not, return a 'Sorry you're not the owner' &amp;amp; 'Logout' button.&lt;/li&gt;
&lt;li&gt;If they pass both of these checks the user must be logged in &amp;amp; the owner of the current store. So, we will leave the default return in place.&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;li&gt;Set the default state of the &lt;code&gt;uid&lt;/code&gt; &amp;amp; &lt;code&gt;owner&lt;/code&gt; to &lt;code&gt;null&lt;/code&gt; (in the Constructor method).&lt;/li&gt;

&lt;li&gt;Create &amp;amp; bind an &lt;code&gt;authenticate&lt;/code&gt; method that takes in &lt;code&gt;provider&lt;/code&gt;. Import base (to connect to Firebase). Use the &lt;code&gt;base.AuthWithOAuthPopup&lt;/code&gt; method.&lt;/li&gt;

&lt;li&gt;Create &amp;amp; bind an &lt;code&gt;authHandler&lt;/code&gt; method that handles errors &amp;amp; returns the User information payload from Firebase. Store the User Information in the state.&lt;/li&gt;

&lt;li&gt;Pass the &lt;code&gt;storeID&lt;/code&gt; down from &lt;code&gt;App&lt;/code&gt; to &lt;code&gt;Inventory&lt;/code&gt; via props.&lt;/li&gt;

&lt;li&gt;Grab the store information from Firebase.&lt;/li&gt;

&lt;li&gt;Check whether the store has an owner set, if not, set the current user as the owner.&lt;/li&gt;

&lt;li&gt;Hook into the &lt;code&gt;componentDidMount&lt;/code&gt; lifecycle method and check to see if there is an authenticated user present. If so, call the &lt;code&gt;authHandler&lt;/code&gt; method.&lt;/li&gt;

&lt;li&gt;Hook up the &lt;code&gt;Log Out&lt;/code&gt; button.&lt;/li&gt;

&lt;li&gt;Increase the security of the database rules in Firebase.&lt;/li&gt;

&lt;/ul&gt;

&lt;h6&gt;
  
  
  Today the app looks like:
&lt;/h6&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%2Fs3-ap-southeast-2.amazonaws.com%2Fghost-blog-stef-ninja%2F2017%2F07%2Fday24-1501467423406.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%2Fs3-ap-southeast-2.amazonaws.com%2Fghost-blog-stef-ninja%2F2017%2F07%2Fday24-1501467423406.png" alt="App on Day 24 of the React for Beginners Course"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;This will be the last image I put up detailing the App progress as the final lessons are around deployment (with no visual changes).&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;[Video 24: Authentication]&lt;/em&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Day 25: Building React for Production
&lt;/h3&gt;

&lt;p&gt;&lt;code&gt;create-react-app&lt;/code&gt; has a build step. It is as simple as running the command &lt;code&gt;npm run build&lt;/code&gt; in the terminal. This process exports all of the files that we will need to run our app in production. This includes minifying the JS and CSS files and creating source-maps for our JS and CSS. These source-maps will make debugging our app 100% easier by referencing the JS or CSS file that the code was written in rather than the compiled line.&lt;/p&gt;

&lt;p&gt;It also outlines how to upload and run this on both a local and a remote server.&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%2Fs3-ap-southeast-2.amazonaws.com%2Fghost-blog-stef-ninja%2F2017%2F08%2Fterminal_output_from_npm_run_build-1501644417629.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%2Fs3-ap-southeast-2.amazonaws.com%2Fghost-blog-stef-ninja%2F2017%2F08%2Fterminal_output_from_npm_run_build-1501644417629.png" alt="Terminal output after running npm run build"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The &lt;code&gt;create-react-app&lt;/code&gt; output at the top level is &lt;code&gt;index.html&lt;/code&gt; and a &lt;code&gt;static&lt;/code&gt; folder. This output doesn't come with an actual server. This means that if we just uploaded these files onto a server we would be served a bunch of errors. We need a server that knows to serve the &lt;code&gt;index.html&lt;/code&gt; regardless of the URL and that relinquishes the routing to the browser.&lt;/p&gt;

&lt;p&gt;The next few lessons will be covering how to deploy this app onto various servers that fit this bill. As these are all related to building React for Production I will complete them all today.&lt;/p&gt;

&lt;h5&gt;
  
  
  Deploying to now.sh
&lt;/h5&gt;

&lt;p&gt;&lt;a href="https://zeit.co/now" rel="noopener noreferrer"&gt;now.sh&lt;/a&gt; publishes your JavaScript (Node.js) or docker powered apps, websites and services in the cloud easily, quickly and reliably. It also comes with free open source hosting. This means deployment of anything you're happy to open source is quick, free (up to a limit) and easy. &lt;/p&gt;

&lt;p&gt;The &lt;code&gt;now-serve&lt;/code&gt; (found &lt;a href="https://github.com/zeit/now-serve" rel="noopener noreferrer"&gt;here&lt;/a&gt;) command that Wes uses is depreciated and instead we are directed to use &lt;code&gt;now-static&lt;/code&gt; (found &lt;a href="https://zeit.co/blog/now-static" rel="noopener noreferrer"&gt;here&lt;/a&gt;). I was unable to get this working today and will revisit it after learning the other deployment processes.&lt;/p&gt;

&lt;h6&gt;
  
  
  To Do:
&lt;/h6&gt;

&lt;ul&gt;
&lt;li&gt;Run &lt;code&gt;npm run build&lt;/code&gt; command.&lt;/li&gt;
&lt;li&gt;Choose a server to deploy to.&lt;/li&gt;
&lt;li&gt;Deploy to a server.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;em&gt;[Video 25 &amp;amp; 26: Building React for Production, Deploying to now.sh]&lt;/em&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Day 26: Deploying to GitHub Pages
&lt;/h3&gt;

&lt;p&gt;Another (hacky) way that we can host our &lt;code&gt;create-react-app&lt;/code&gt; application is by using &lt;a href="https://pages.github.com/" rel="noopener noreferrer"&gt;GitHub Pages&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;This process is 'hacky' because we need to work around the fact that our Application will be hosted in a subfolder (rather than the root directory). To account for this before running the build process we need to add &lt;code&gt;"homepage": "https://YOURGITHUBNAME.github.io/YOURREPONAME"&lt;/code&gt;. We will also need to alter the React Router to account for this subfolder.&lt;/p&gt;

&lt;p&gt;GitHub pages doesn't allow you to control the routing for your pages so the suggested (hacky) way around this is to duplicate the &lt;code&gt;index.html&lt;/code&gt; page and rename the copy as &lt;code&gt;404.html&lt;/code&gt;. This will mean that everytime the browser receives a 404 code the app is still presented. I hate this as a concept and am immediately taking this page down &amp;amp; deleting this repo.&lt;/p&gt;

&lt;h6&gt;
  
  
  To Do:
&lt;/h6&gt;

&lt;ul&gt;
&lt;li&gt;Set up a blank GitHub repo.&lt;/li&gt;
&lt;li&gt;Set &lt;code&gt;homepage&lt;/code&gt; in &lt;code&gt;package.json&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Modify &lt;code&gt;react-router&lt;/code&gt; (in &lt;code&gt;index.js&lt;/code&gt;) to run in a subfolder. (set the attribute 'basename' equal to the subfolder name). You can do this by getting the variable from the URL with:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const repo = `/${window.location.pathname.split('/')[1]}`;
const Root = ()
...
&amp;lt;BrowserRouter basename={repo} &amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;run &lt;code&gt;npm run build&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;From the new build directory initialise a new Git Repo (with &lt;code&gt;git init&lt;/code&gt;).&lt;/li&gt;
&lt;li&gt;Add the remote (with &lt;code&gt;git remote add origin git@github.com:YOURGITHUBNAME/YOURREPONAME.git&lt;/code&gt;)&lt;/li&gt;
&lt;li&gt;Run &lt;code&gt;git add -A&lt;/code&gt;, &lt;code&gt;git commit -m "fishy"&lt;/code&gt;, &lt;code&gt;git push -u origin master&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;In the settings of your GitHub repo publish the &lt;code&gt;master branch&lt;/code&gt; as the source for your GitHub page.&lt;/li&gt;
&lt;li&gt;Duplicate &lt;code&gt;index.html&lt;/code&gt; as &lt;code&gt;404.html&lt;/code&gt; &amp;amp; commit &amp;amp; push this change.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;em&gt;[Video 27: Deploying to GitHub Pages]&lt;/em&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Day 27: Deploying to an Apache Server
&lt;/h3&gt;

&lt;p&gt;Now we're getting into the good stuff. Today we're deploying on a standard Apache server (like the kind you pick up from GoDaddy or Bluehost for a couple of bucks a month).&lt;/p&gt;

&lt;p&gt;If you're going to deploy to a subdirectory (not the root domain or a subdomain) then you will need to update the &lt;code&gt;react-router&lt;/code&gt; information in &lt;code&gt;index.js&lt;/code&gt; and the &lt;code&gt;hompage:&lt;/code&gt; declaration in &lt;code&gt;package.json&lt;/code&gt;. If not, these additions can be deleted.&lt;/p&gt;

&lt;p&gt;We need to tell the server that &lt;code&gt;index.html&lt;/code&gt; should be served for ALL routes. For an Apache server you can do this with a &lt;code&gt;.htaccess&lt;/code&gt; file. Enter the following:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;RewriteBase /
RewriteRule ^index\.html$ - [L]
RewriteCond %{REQUEST_FILENAME}% !-f
RewriteCond %{REQUEST_FILENAME}% !-d
RewriteRule . /index.html [L]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;These rules breakdown to - whenever you have ANY &lt;code&gt;/&lt;/code&gt; serve up either the requested filename OR if nothing is found then serve up &lt;code&gt;index.html&lt;/code&gt; instead.&lt;/p&gt;

&lt;p&gt;Note: To do this for an &lt;code&gt;nginx&lt;/code&gt; server you could use the following in an &lt;code&gt;nginx.conf&lt;/code&gt; file:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;location / {
    try_files $uri /index.html;
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h6&gt;
  
  
  To Do:
&lt;/h6&gt;

&lt;ul&gt;
&lt;li&gt;run &lt;code&gt;npm run build&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;FTP these files up to your Apache server.&lt;/li&gt;
&lt;li&gt;Create a &lt;code&gt;.htaccess&lt;/code&gt; file.&lt;/li&gt;
&lt;li&gt;Allow the domain on Firebase (so your login OAuth continues to work)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;em&gt;[Video 28: Deploying to an Apache Server]&lt;/em&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Day 28: Property Initializers and Getting Rid of .bind()
&lt;/h3&gt;

&lt;p&gt;Anytime we want to add a custom method that we want bound to the instance of our component we need to use &lt;code&gt;.bind()&lt;/code&gt; in the constructor method. This is a lot of repeated and convoluted code and in today's lesson Wes shows us how to get rid of it using public class fields that are proposed for future iterations of JavaScript (ES6).&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Note: Wes references the &lt;a href="https://github.com/tc39/proposal-class-public-fields" rel="noopener noreferrer"&gt;ES Class Fields &amp;amp; Static Properties&lt;/a&gt; proposal to JavaScript but this has since been merged with another proposal to form the &lt;a href="https://github.com/tc39/proposal-class-fields" rel="noopener noreferrer"&gt;ESnext class features for JavaScript&lt;/a&gt;.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;So how does these Property Initializers relate to removing &lt;code&gt;.bind()&lt;/code&gt;?&lt;/p&gt;

&lt;p&gt;We can remove this from the &lt;code&gt;constructor()&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;this.loadSamples = this.loadSamples.bind(this)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;We then alter the method from:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;loadSamples() {
  this.setState({
    fishes: sampleFishes
    });
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;TO:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;loadSamples = () =&amp;gt; {
  this.setState({
    fishes: sampleFishes
    });
};
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This works because the &lt;a href="https://googlechrome.github.io/samples/arrows-es6/" rel="noopener noreferrer"&gt;arrow function&lt;/a&gt; binds to the parent (essentially doing the same work as the &lt;code&gt;.bind()&lt;/code&gt; we were using earlier with much less hassle). &lt;em&gt;It is important to note that this is a feature that hasn't been implemented into JavaScript yet and there is no guarantee that it ever will.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;We are also able to remove any state declarations that were made within the &lt;code&gt;constructor()&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;this.state = {
  fishes: {},
  order:{}
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;We can then remove the dot notation and set it outside of the &lt;code&gt;constructor()&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;state = {
  fishes: {},
  order:{}
};
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This is a property Initializer that has been added to every instance of App. This means that every instance of this component will be initialised with this state.&lt;/p&gt;

&lt;p&gt;Futher dot notation removal can happen to anything that needs to happen after the component. For example, our propTypes are checked below the &lt;code&gt;render()&lt;/code&gt; of the component. These can be moved inside the component return and given a &lt;code&gt;static&lt;/code&gt; flag (as we don't need a new version everytime there is a new instance of this component).&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;App.propTypes = {
  params: React.PropTypes.object.isRequired,
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This can be moved into the &lt;code&gt;render()&lt;/code&gt; function and modified to:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;static propTypes = {
  params: React.PropTypes.object.isRequired,
};
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h6&gt;
  
  
  To Do:
&lt;/h6&gt;

&lt;ul&gt;
&lt;li&gt;Replace &lt;code&gt;.bind()&lt;/code&gt; Property Initializers.&lt;/li&gt;
&lt;li&gt;Move all &lt;code&gt;propTypes&lt;/code&gt; into the component &amp;amp; make them static.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;em&gt;[Video 29: Future React Today - Property Initializers and getting rid of .bind()]&lt;/em&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Day 29: Throwing Away the create-react-app Parachute
&lt;/h3&gt;

&lt;p&gt;&lt;code&gt;create-react-app&lt;/code&gt; is brilliant because it handles all of the hard behind the scenes magic (cough webpack cough) and allows you to just get in there and start creating. However, there may be a time where the default set up isn't going to work for you any more and you need to eject from &lt;code&gt;create-react-app&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Warning: There is no way to 'uneject' from create-react-app so make sure you are doing this on a GitHub branch.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Ejecting from &lt;code&gt;create-react-app&lt;/code&gt; is as simple as runinng the command &lt;code&gt;npm run eject&lt;/code&gt;. &lt;/p&gt;

&lt;p&gt;It will then install all of the dependencies that the app needs to work. It will also create two new directories (config &amp;amp; scripts). It will also add a literal butt-tonne of &lt;code&gt;devDependencies&lt;/code&gt; to your &lt;code&gt;package.json&lt;/code&gt; file. &lt;/p&gt;

&lt;p&gt;You can now edit and update the webpack config, eslintConfig and babel as needed. &lt;/p&gt;

&lt;h6&gt;
  
  
  To Do:
&lt;/h6&gt;

&lt;ul&gt;
&lt;li&gt;Create new &lt;code&gt;ejected&lt;/code&gt; branch in repo&lt;/li&gt;
&lt;li&gt;Run command &lt;code&gt;npm run eject&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Customise as needed.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;em&gt;[Video 30: Ejecting from create-react-app]&lt;/em&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Day 30: Deploying to Firebase
&lt;/h3&gt;

&lt;p&gt;It's the last day of my 30 day challenge and I have run out of official &lt;code&gt;React for Beginners&lt;/code&gt; lessons. The one thing that I was curious about during the last couple of lessons is how we could use Firebase to host the app (as well as handle the persistent state management with the database). I'm also curious if we would be given enough control over the routing to server &lt;code&gt;index.html&lt;/code&gt; regardless of the location.&lt;/p&gt;

&lt;p&gt;With a little bit of quick research I can see that this is not only possible but it looks as though Firebase is built for it. So without further ado, let's get this app deployed onto Firebase hosting.&lt;/p&gt;

&lt;h6&gt;
  
  
  Deploying create-react-app to Firebase
&lt;/h6&gt;

&lt;p&gt;The &lt;code&gt;create-react-app&lt;/code&gt; documentation goes through how to deploy your app to Firebase. Follow the instructions &lt;a href="https://github.com/facebookincubator/create-react-app/blob/master/packages/react-scripts/template/README.md#firebase" rel="noopener noreferrer"&gt;here&lt;/a&gt; (as they will be better than anything I can describe).&lt;/p&gt;

&lt;h6&gt;
  
  
  Customising Hosting Behaviour on Firebase
&lt;/h6&gt;

&lt;p&gt;Firebase opens up the control of how content is hosted - this includes custom error pages, redirects, rewrites and headers. In our case, we're interested in &lt;a href="https://firebase.google.com/docs/hosting/url-redirects-rewrites" rel="noopener noreferrer"&gt;rewrites&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;To do this I added some customisations to the &lt;code&gt;firebase.json&lt;/code&gt; document. My additions tell Firebase to make &lt;code&gt;build&lt;/code&gt; the public directory and redirect all routes to the &lt;code&gt;index.html&lt;/code&gt; file. It also tells it to ignore the files that don't need to be included in deployment.  &lt;/p&gt;

&lt;p&gt;It now reads like:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;{
  "hosting": {
    "public": "build",
    "rewrites": [{
      "source": "**",
      "destination": "/index.html"
    }],
    "ignore": [
      "firebase.json",
      "**/.*",
      "**/node_modules/**"
    ]
  }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now you can view my App &lt;a href="https://catch-of-the-day-published.firebaseapp.com/" rel="noopener noreferrer"&gt;here&lt;/a&gt; if you ever want to check it out.&lt;/p&gt;

&lt;h6&gt;
  
  
  To Do:
&lt;/h6&gt;

&lt;ul&gt;
&lt;li&gt;Install Firebase CLI.&lt;/li&gt;
&lt;li&gt;Run the &lt;code&gt;create-react-app&lt;/code&gt; build command.&lt;/li&gt;
&lt;li&gt;Customise the &lt;code&gt;firebase.json&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Deploy to Firebase.&lt;/li&gt;
&lt;/ul&gt;




&lt;p&gt;Read more in this series: &lt;a href="https://stef.ninja/learning-react-week-1/" rel="noopener noreferrer"&gt;Week 1&lt;/a&gt;, &lt;a href="https://stef.ninja/learning-react-week-2/" rel="noopener noreferrer"&gt;Week 2&lt;/a&gt;, and &lt;a href="https://stef.ninja/learning-react-week-3/" rel="noopener noreferrer"&gt;Week 3&lt;/a&gt; &lt;strong&gt;Or&lt;/strong&gt; get the &lt;a href="https://reactforbeginners.com/" rel="noopener noreferrer"&gt;React for Beginners Course&lt;/a&gt; for yourself.&lt;/p&gt;

</description>
      <category>react</category>
      <category>javascript</category>
      <category>beginners</category>
    </item>
    <item>
      <title>Learning React - Week 3</title>
      <dc:creator>Stef Cola</dc:creator>
      <pubDate>Thu, 03 Aug 2017 04:29:46 +0000</pubDate>
      <link>https://dev.to/stefdotninja/learning-react---week-3</link>
      <guid>https://dev.to/stefdotninja/learning-react---week-3</guid>
      <description>&lt;p&gt;This article originally appeared on &lt;a href="https://stef.ninja/learning-react-week-3/" rel="noopener noreferrer"&gt;stef.ninja&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;This is the third post in a series of notes from the &lt;a href="https://reactforbeginners.com/" rel="noopener noreferrer"&gt;React for Beginners&lt;/a&gt; course from &lt;a href="https://twitter.com/wesbos" rel="noopener noreferrer"&gt;Wes Bos&lt;/a&gt; that I am working through. This is an &lt;strong&gt;AWESOME&lt;/strong&gt; course and I highly recommend it to anyone looking to learn React. &lt;/p&gt;

&lt;p&gt;You can find more notes in &lt;a href="https://dev.to/learning-react-week-1/"&gt;Week 1&lt;/a&gt; and &lt;a href="https://dev.to/learning-react-week-2/"&gt;Week 2&lt;/a&gt; of the series.&lt;/p&gt;

&lt;h3&gt;
  
  
  Day 15: Display Data from the State
&lt;/h3&gt;

&lt;p&gt;We have the sample fish data saved in our state. Let's get these fish displaying in the UI.&lt;/p&gt;

&lt;p&gt;JSX doesn't have any loops or logic built in so to combat this we can use regular javascript (by encapsulating it in {}). To display a list of our sample fish we will map over the entire list of keys within the &lt;code&gt;fish&lt;/code&gt; object like so:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;ul class="list-of-fishes"&amp;gt;
  {
    Object
      .keys(this.state.fishes)
      .map(key =&amp;gt; &amp;lt;Fish key={key} /&amp;gt;)
  }
&amp;lt;/ul&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Wes gives a good tip around &lt;a href="https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Operators/Destructuring_assignment" rel="noopener noreferrer"&gt;ES6 destructuring&lt;/a&gt; that means when we are referencing the props that are sent down to the child we don't have to repeat ourselves with &lt;code&gt;this.props&lt;/code&gt; all of the time.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const {details} = this.props;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Further reading: Wes Bos has &lt;a href="http://wesbos.com/destructuring-objects/" rel="noopener noreferrer"&gt;A Dead Simple intro to Destructuring JavaScript Objects&lt;/a&gt;&lt;/p&gt;

&lt;h6&gt;
  
  
  To Do:
&lt;/h6&gt;

&lt;ul&gt;
&lt;li&gt;Pass the details about each fish down to the Fish component via the &lt;code&gt;details&lt;/code&gt; prop. Hint: &lt;code&gt;details={this.state.fishes[key]}&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Use the formatPrice function in the helper file to format the Price detail.&lt;/li&gt;
&lt;li&gt;Make a component (Fish.js) that displays the data for each fish. Return this all in a &lt;code&gt;&amp;lt;li&amp;gt;&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Iterate through a list of the sample fish in the fish object &amp;amp; display the Fish component.&lt;/li&gt;
&lt;/ul&gt;

&lt;h6&gt;
  
  
  Today the app looks like:
&lt;/h6&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%2Fs3-ap-southeast-2.amazonaws.com%2Fghost-blog-stef-ninja%2F2017%2F07%2Fday15-1500008561302.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%2Fs3-ap-southeast-2.amazonaws.com%2Fghost-blog-stef-ninja%2F2017%2F07%2Fday15-1500008561302.png" alt="App on Day 15 of the React for Beginners Course"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;[Video 15: Displaying State with JSX]&lt;/em&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Day 16: Updating State
&lt;/h3&gt;

&lt;p&gt;Today we're linking up the &lt;code&gt;Add To Order&lt;/code&gt; button so it actually adds the corresponding fish to the state.&lt;/p&gt;

&lt;p&gt;The button has an awesome feature where it dynamically changes depending on whether a fish is available or not. To do this we will be implementing some logic around &lt;code&gt;details.status&lt;/code&gt; using a &lt;a href="https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Operators/Conditional_Operator" rel="noopener noreferrer"&gt;ternary operator&lt;/a&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const isAvailable = details.status === 'available';
const buttonText = isAvailable ? 'Add To Order' : 'Sold Out!';
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h6&gt;
  
  
  To Do:
&lt;/h6&gt;

&lt;ul&gt;
&lt;li&gt;Change the content of our &lt;code&gt;Add To Order&lt;/code&gt; button to be dynamic depending on the &lt;code&gt;details.status&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Change the button to be disabled if the fish is unavailable.&lt;/li&gt;
&lt;li&gt;Add &lt;code&gt;addToOrder&lt;/code&gt; method on the app component.
//Take a copy of the state
//Update the new number of fish ordered e.g &lt;code&gt;order[key] = order[key] + 1 || 1;&lt;/code&gt;
//Update state.&lt;/li&gt;
&lt;li&gt;Bind the method to the app component.&lt;/li&gt;
&lt;li&gt;Pass the &lt;code&gt;addToOrder&lt;/code&gt; down to our child via props.&lt;/li&gt;
&lt;li&gt;Add an &lt;code&gt;onClick&lt;/code&gt; handler to the button that updates the state of the order. Note: To do this we will need a reference to the key. Pass this down as a prop on the Fish component.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Quick Note: I send these notes over to my best dev friend &lt;a href="https://twitter.com/markacola" rel="noopener noreferrer"&gt;Mark&lt;/a&gt; to read through before publishing &amp;amp; he always gives me great notes on things that I'm not 100% across. Below are his notes on the function that we used to update the number of fish ordered:&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;If the &lt;code&gt;key&lt;/code&gt; isn't set in &lt;code&gt;order&lt;/code&gt; then &lt;code&gt;order[key]&lt;/code&gt; will return &lt;code&gt;undefined&lt;/code&gt;, which means &lt;code&gt;order[key] + 1&lt;/code&gt; =&amp;gt; &lt;code&gt;undefined + 1&lt;/code&gt; =&amp;gt; &lt;code&gt;NaN&lt;/code&gt;, and because &lt;code&gt;NaN&lt;/code&gt; is falsey the &lt;code&gt;1&lt;/code&gt; in the &lt;code&gt;NaN || 1&lt;/code&gt; expression is returned. It is small but important to understand the sequence of transforms that the data goes through so you don't get tripped up later on.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h6&gt;
  
  
  Today the app looks like:
&lt;/h6&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%2Fs3-ap-southeast-2.amazonaws.com%2Fghost-blog-stef-ninja%2F2017%2F07%2Fday15-1500008561302.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%2Fs3-ap-southeast-2.amazonaws.com%2Fghost-blog-stef-ninja%2F2017%2F07%2Fday15-1500008561302.png" alt="App on Day 16 of the React for Beginners Course"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;It looks exactly the same as yesterday because we didn't make any UI changes.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;[Video 16: Updating Order State]&lt;/em&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Day 17: Display State via JSX
&lt;/h3&gt;

&lt;p&gt;In today's lesson we are taking the &lt;code&gt;order&lt;/code&gt; state that we have been working with and injecting it into the UI via JSX.&lt;/p&gt;

&lt;p&gt;This is the first time that we are calling another method within the render method to handle a fair bit of our JSX output. Wes mentions that this can be done using another component but he has opted to an additional method within the Order.js component to keep it simpler (no need to hand down props once we bind it).&lt;/p&gt;

&lt;h6&gt;
  
  
  To Do:
&lt;/h6&gt;

&lt;p&gt;Todays Goal: Display fish order via &lt;code&gt;Order.js&lt;/code&gt;. This component needs to include the number of lbs, name of fish, total cost of each line item, and total cost. We will do this by:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Passing the &lt;code&gt;fishes&lt;/code&gt; &amp;amp; &lt;code&gt;order&lt;/code&gt; state to the order component via props.&lt;/li&gt;
&lt;li&gt;Create a running total price of all of the fish included in the order.&lt;/li&gt;
&lt;li&gt;Importing and using the &lt;code&gt;formatPrice()&lt;/code&gt; function from the helpers file.&lt;/li&gt;
&lt;li&gt;Creating a &lt;code&gt;renderOrder()&lt;/code&gt; function within the Order component to handle the JSX returned for each fish within the order. This can be called from within the &lt;code&gt;render()&lt;/code&gt; function like this: &lt;code&gt;{orderIds.map(this.renderOrder)}&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Bind our custom method to this via a constructor.&lt;/li&gt;
&lt;li&gt;Remember to add the key to all list items to ensure that React can reference them.&lt;/li&gt;
&lt;/ul&gt;

&lt;h6&gt;
  
  
  Today the app looks like:
&lt;/h6&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%2Fs3-ap-southeast-2.amazonaws.com%2Fghost-blog-stef-ninja%2F2017%2F07%2Fday_17_catch_of_the_day-1500604761179.gif" 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%2Fs3-ap-southeast-2.amazonaws.com%2Fghost-blog-stef-ninja%2F2017%2F07%2Fday_17_catch_of_the_day-1500604761179.gif" alt="App on Day 17 of the React for Beginners Course"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;[Video 17: Displaying Order State with JSX]&lt;/em&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Day 18:
&lt;/h3&gt;

&lt;p&gt;Persiting data requires a backend service. In this lesson we use &lt;a href=""&gt;Firebase&lt;/a&gt; from Google as our backend service.&lt;/p&gt;

&lt;p&gt;It uses &lt;a href="https://developer.mozilla.org/en-US/docs/Web/API/WebSocket" rel="noopener noreferrer"&gt;HTML5 Websockets&lt;/a&gt; which Wes was pretty excited about but I had to do some research around. This video was a really good explanation of it with an example: &lt;a href="https://www.youtube.com/watch?v=ZSRNNqh5Xo8" rel="noopener noreferrer"&gt;Introduction to Websockets and Firebase - How to Build Real-Time Apps&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;So with Firebase we have a realtime backend database. A great feature of the Firebase Realtime Database is that it is basically a giant object. Which syncs perfectly with React State also being an object.&lt;/p&gt;

&lt;p&gt;During this lesson we also explored the &lt;a href="https://facebook.github.io/react/docs/state-and-lifecycle.html" rel="noopener noreferrer"&gt;React Lifecycle Hooks&lt;/a&gt;. These lifecycle methods offer us different entry points into a component.&lt;/p&gt;

&lt;p&gt;We focussed on the componentWillMount method that is invoked before the initial component is rendered. This is a great time to sync the database object with our state object. It also has a coupled componentWillUnmount method that allows us to break the connection.&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%2Fs3-ap-southeast-2.amazonaws.com%2Fghost-blog-stef-ninja%2F2017%2F07%2Fday_18_componentWillMount-1500611498129.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%2Fs3-ap-southeast-2.amazonaws.com%2Fghost-blog-stef-ninja%2F2017%2F07%2Fday_18_componentWillMount-1500611498129.png" alt="Code in App.js used to connect to the database via re-base"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h5&gt;
  
  
  To Do:
&lt;/h5&gt;

&lt;ul&gt;
&lt;li&gt;Sign up for a Firebase account.&lt;/li&gt;
&lt;li&gt;Create a new Project in Firebase.&lt;/li&gt;
&lt;li&gt;Edit the Realtime Database rules to be less secure (don't worry we will fix this us in the authentication lesson set for day 24). Set the Realtime Database rules to:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;{
  "rules": {
    ".read": true,
    ".write": true
  }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Use the &lt;a href="https://www.npmjs.com/package/re-base" rel="noopener noreferrer"&gt;re-base&lt;/a&gt; package to implement Firebase into the React app with the following being entered into &lt;code&gt;base.js&lt;/code&gt;:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import Rebase from 're-base';

//Get some information from your Firebase project
const base = Rebase.createClass({
    apiKey: YOUR API KEY,
    authDomain: YOUR AUTH DOMAIN,
    databaseURL: YOUR DATABASE URL,
  });

export default base;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;import &lt;code&gt;base&lt;/code&gt; into the App&lt;/li&gt;
&lt;li&gt;Hook into the &lt;code&gt;componentWillMount()&lt;/code&gt; lifecycle method to sync the App state with the Firebase Realtime database.&lt;/li&gt;
&lt;/ul&gt;

&lt;h6&gt;
  
  
  Today the app looks like:
&lt;/h6&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%2Fs3-ap-southeast-2.amazonaws.com%2Fghost-blog-stef-ninja%2F2017%2F07%2Fday18_firebase-1500611512648.gif" 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%2Fs3-ap-southeast-2.amazonaws.com%2Fghost-blog-stef-ninja%2F2017%2F07%2Fday18_firebase-1500611512648.gif" alt="App on Day 18 of the React for Beginners Course"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;[Video 18: Persisting our State with Firebase]&lt;/em&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Day 19: Persisting State with localstorage
&lt;/h3&gt;

&lt;p&gt;In todays lesson we explored persisting the state of our order via &lt;a href="https://www.w3schools.com/html/html5_webstorage.asp" rel="noopener noreferrer"&gt;HTML5 Local Storage&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Local Storage allows us to store the data associated with the order within the browser. It is a good option for the order to be stored in because it is secure, local and doesn't impact on website performance.&lt;/p&gt;

&lt;p&gt;Local Storage uses key value pairs. The value only accepts numbers, strings or booleans. This means we need to transform our order object into a string. We can do this via the &lt;code&gt;JSON.stringify()&lt;/code&gt; method (you can always turn it back with &lt;code&gt;JSON.parse()&lt;/code&gt;).&lt;/p&gt;

&lt;p&gt;We were also using the &lt;a href="https://facebook.github.io/react/docs/react-component.html" rel="noopener noreferrer"&gt;React Lifecycle Methods&lt;/a&gt; in this lesson. Specifically the &lt;code&gt;componentWillUpdate&lt;/code&gt; method that is invoked immediately before rendering when new props or state are being received. This method also isn't called for the initial render which suits this data object (order) well.&lt;/p&gt;

&lt;p&gt;The Lifecycle methods on &lt;code&gt;&amp;lt;App&amp;gt;&lt;/code&gt; currently look like:&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fs3-ap-southeast-2.amazonaws.com%2Fghost-blog-stef-ninja%2F2017%2F07%2Fday19_lifecycle-1500620253486.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%2Fs3-ap-southeast-2.amazonaws.com%2Fghost-blog-stef-ninja%2F2017%2F07%2Fday19_lifecycle-1500620253486.png" alt="Lifecycle methods"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h5&gt;
  
  
  To Do:
&lt;/h5&gt;

&lt;ul&gt;
&lt;li&gt;Pass down all of the params to the &lt;code&gt;&amp;lt;Order&amp;gt;&lt;/code&gt; component.&lt;/li&gt;
&lt;li&gt;Hook into the &lt;code&gt;componentWillUpdate&lt;/code&gt; method and set the localStorage to our &lt;code&gt;order&lt;/code&gt; state.&lt;/li&gt;
&lt;li&gt;Hook into the &lt;code&gt;componentWillMount&lt;/code&gt; method (already called) and check whether there is any order in localStorage.&lt;/li&gt;
&lt;li&gt;If there is an order saved in localStorage then update the  order state.&lt;/li&gt;
&lt;/ul&gt;
&lt;h6&gt;
  
  
  Today the app looks like:
&lt;/h6&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%2Fs3-ap-southeast-2.amazonaws.com%2Fghost-blog-stef-ninja%2F2017%2F07%2Fday_19_localstorage-1500620458400.gif" 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%2Fs3-ap-southeast-2.amazonaws.com%2Fghost-blog-stef-ninja%2F2017%2F07%2Fday_19_localstorage-1500620458400.gif" alt="App on Day 19 of the React for Beginners Course"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;[Video 19: Persisting Order State with localstorage]&lt;/em&gt;&lt;/p&gt;
&lt;h3&gt;
  
  
  Day 20: Live State Editing with Bi-directional State
&lt;/h3&gt;

&lt;p&gt;Today was a pretty involved lesson. We managed to set up state editing via the inventory management from the UI of the app. &lt;/p&gt;

&lt;p&gt;First we needed to create a form for each of the fish objects within our state. This was done in the &lt;code&gt;Inventory&lt;/code&gt; component via a new &lt;code&gt;renderInventory()&lt;/code&gt; method we created:&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%2Fs3-ap-southeast-2.amazonaws.com%2Fghost-blog-stef-ninja%2F2017%2F07%2Fday20_renderInventorymethod-1500872408641.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%2Fs3-ap-southeast-2.amazonaws.com%2Fghost-blog-stef-ninja%2F2017%2F07%2Fday20_renderInventorymethod-1500872408641.png" alt="renderInventory method that we created today"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Once the form had been created we needed a new method to handle the updates. This was done with the &lt;code&gt;handleChange&lt;/code&gt; method that we created:&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%2Fs3-ap-southeast-2.amazonaws.com%2Fghost-blog-stef-ninja%2F2017%2F07%2Fday20_handlechange-1500872560726.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%2Fs3-ap-southeast-2.amazonaws.com%2Fghost-blog-stef-ninja%2F2017%2F07%2Fday20_handlechange-1500872560726.png" alt="handleChange method that we created today"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The final method we added was on the App component and it made the magic happen. The state is only updated via the App component so this is why everything had to be passed up there. &lt;/p&gt;

&lt;p&gt;This pattern of copy the current state, overwrite the section that has changed, then update the state is becoming a go to when writing React code. &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%2Fs3-ap-southeast-2.amazonaws.com%2Fghost-blog-stef-ninja%2F2017%2F07%2Fday20_updatefish-1500872669590.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%2Fs3-ap-southeast-2.amazonaws.com%2Fghost-blog-stef-ninja%2F2017%2F07%2Fday20_updatefish-1500872669590.png" alt="updateFish method that we created on the App component today"&gt;&lt;/a&gt;&lt;/p&gt;


&lt;h6&gt;
  
  
  Note from Mark:
&lt;/h6&gt;

&lt;p&gt;Passing each of these functions inline is a great opportunity to use &lt;a href="https://en.wikipedia.org/wiki/Memoization" rel="noopener noreferrer"&gt;memoization&lt;/a&gt;. Currently, with every change that is put through any of those inputs all children are re-rendered. This isn't a giant performance suck at this level as they are only inputs (not large components) but it is good to get into the habit of memoization early. &lt;/p&gt;

&lt;p&gt;We used &lt;a href="https://lodash.com/docs/#memoize" rel="noopener noreferrer"&gt;lodash.memoize&lt;/a&gt;. This is the improved functions that we worked out:&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%2Fs3-ap-southeast-2.amazonaws.com%2Fghost-blog-stef-ninja%2F2017%2F07%2Fday20_lodashmemoize_improvement-1500879417158.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%2Fs3-ap-southeast-2.amazonaws.com%2Fghost-blog-stef-ninja%2F2017%2F07%2Fday20_lodashmemoize_improvement-1500879417158.png" alt="Improved function performance using memoize"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Further reading on this:&lt;br&gt;
&lt;a href="https://lodash.com/docs/#memoize" rel="noopener noreferrer"&gt;Lodash memoize&lt;/a&gt;&lt;br&gt;
&lt;a href="https://rob-bell.net/2009/06/a-beginners-guide-to-big-o-notation/" rel="noopener noreferrer"&gt;The Big O Notation&lt;/a&gt;&lt;/p&gt;
&lt;h5&gt;
  
  
  To Do:
&lt;/h5&gt;

&lt;ul&gt;
&lt;li&gt;Loop over all of the fish within the state and output an inventory management form (much like the new fish form)&lt;/li&gt;
&lt;li&gt;Pass &lt;code&gt;fishes&lt;/code&gt; down to &lt;code&gt;&amp;lt;Inventory /&amp;gt;&lt;/code&gt; via props.&lt;/li&gt;
&lt;li&gt;Create &lt;code&gt;renderInventory()&lt;/code&gt; method that will handle all of the form rendering.&lt;/li&gt;
&lt;li&gt;Add the current values of the fish (from state) into each section. &lt;/li&gt;
&lt;li&gt;Data bind the values so each time an edit is made this is reflected in the state (and on the Firebase database) (remember to use &lt;code&gt;defaultValue&lt;/code&gt; instead of &lt;code&gt;value&lt;/code&gt; so that the field is mutable). Use &lt;code&gt;onChange{(e) =&amp;gt; this.handleChange(e, key)}&lt;/code&gt;. &lt;/li&gt;
&lt;li&gt;Create a custom &lt;code&gt;handleChange()&lt;/code&gt; method and bind it using the constructor. Within that method take a copy of the fish state. Then use the computed target to update ONLY the element that has changed:
&lt;/li&gt;
&lt;/ul&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;handleChange(e, key) {
  const fish = this.props.fishes[key];
  //Copy the fish and update it with new data
  const updatedFish = {
    ...fish,
    [e.target.name]: e.target.value
  }
  this.props.updateFish(key, updateFish);
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;ul&gt;
&lt;li&gt;Pass the updated fish up to the &lt;code&gt;&amp;lt;App /&amp;gt;&lt;/code&gt; component. &lt;/li&gt;
&lt;li&gt;Create a custom method to set the state of the fishes to the updated fish (use &lt;code&gt;updateFish()&lt;/code&gt;).&lt;/li&gt;
&lt;li&gt;Make the &lt;code&gt;updateFish()&lt;/code&gt; available to the &lt;code&gt;&amp;lt;Inventory /&amp;gt;&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h6&gt;
  
  
  Today the app looks like:
&lt;/h6&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%2Fs3-ap-southeast-2.amazonaws.com%2Fghost-blog-stef-ninja%2F2017%2F07%2Fday20-1500872206503.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%2Fs3-ap-southeast-2.amazonaws.com%2Fghost-blog-stef-ninja%2F2017%2F07%2Fday20-1500872206503.png" alt="App on Day 20 of the React for Beginners Course"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;[Video 20: Bi-directional Data Flow and Live State Editing]&lt;/em&gt;&lt;/p&gt;
&lt;h3&gt;
  
  
  Day 21: Deleting Items from State
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://en.wikipedia.org/wiki/Create,_read,_update_and_delete" rel="noopener noreferrer"&gt;CRUD&lt;/a&gt; (or Create, Read, Update and Delete) is the basic functions required for persistent storage. We have already worked through creating objects to save in the state, reading the state and updating the state. In today's lesson we focus on deleting objects from state.&lt;/p&gt;

&lt;p&gt;To do this we run through a similar pattern to the one I highlighted yesterday:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;removeFish(key) {
  //Copy the current state
  const fishes = { ... this.state.fishes };
  //Delete the specific fish
  //Note: 'null' needs to be used because of Firebase
  fishes[key] = null;
  //Set the State
  this.setState({ fishes });
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;That's it. The fish is now deleted. Obliterated from existence.&lt;/p&gt;

&lt;h5&gt;
  
  
  To Do:
&lt;/h5&gt;

&lt;ul&gt;
&lt;li&gt;Create a &lt;code&gt;removeFish&lt;/code&gt; method that deletes a specific fish from the state.&lt;/li&gt;
&lt;li&gt;Create a &lt;code&gt;Delete Fish&lt;/code&gt; button within the &lt;code&gt;renderInventory&lt;/code&gt; JSX&lt;/li&gt;
&lt;li&gt;Link the &lt;code&gt;onClick&lt;/code&gt; handler up to the &lt;code&gt;removeFish&lt;/code&gt; method.&lt;/li&gt;
&lt;/ul&gt;

&lt;h6&gt;
  
  
  Today the app looks like:
&lt;/h6&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%2Fs3-ap-southeast-2.amazonaws.com%2Fghost-blog-stef-ninja%2F2017%2F07%2Fday21_remove-1500875398012.gif" 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%2Fs3-ap-southeast-2.amazonaws.com%2Fghost-blog-stef-ninja%2F2017%2F07%2Fday21_remove-1500875398012.gif" alt="App on Day 21 of the React for Beginners Course"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;[Video 21: Removing Items from State]&lt;/em&gt;&lt;/p&gt;




&lt;p&gt;Read more in this series: &lt;a href="https://stef.ninja/learning-react-week-1/" rel="noopener noreferrer"&gt;Week 1&lt;/a&gt;, &lt;a href="https://stef.ninja/learning-react-week-2/" rel="noopener noreferrer"&gt;Week 2&lt;/a&gt;, and &lt;a href="https://stef.ninja/learning-react-week-4/" rel="noopener noreferrer"&gt;Week 4&lt;/a&gt; &lt;strong&gt;Or&lt;/strong&gt; get the &lt;a href="https://reactforbeginners.com/" rel="noopener noreferrer"&gt;React for Beginners Course&lt;/a&gt; for yourself.&lt;/p&gt;

</description>
      <category>react</category>
      <category>javascript</category>
      <category>beginners</category>
    </item>
    <item>
      <title>Learning React - Week 2</title>
      <dc:creator>Stef Cola</dc:creator>
      <pubDate>Thu, 03 Aug 2017 04:28:36 +0000</pubDate>
      <link>https://dev.to/stefdotninja/learning-react---week-2</link>
      <guid>https://dev.to/stefdotninja/learning-react---week-2</guid>
      <description>&lt;p&gt;This article originally appeared on &lt;a href="https://stef.ninja/learning-react-week-2/" rel="noopener noreferrer"&gt;stef.ninja&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;This is the second week in my 30 days, 30-minute challenge to learn &lt;a href="https://facebook.github.io/react/" rel="noopener noreferrer"&gt;React&lt;/a&gt; via the brilliant course from Wes Bos &lt;a href="https://reactforbeginners.com/" rel="noopener noreferrer"&gt;React for Beginners&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;You can catch the first weeks round up &lt;a href="https://stef.ninja/learning-react-week-1/" rel="noopener noreferrer"&gt;here&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Please note: these posts are in no way a replacement for the course. They are my notes as I progress through the 30 days. I 100% recommend purchasing the course or following Wes Bos on &lt;a href="https://twitter.com/wesbos" rel="noopener noreferrer"&gt;Twitter&lt;/a&gt; if you're interested in React.&lt;/p&gt;

&lt;h3&gt;
  
  
  Day 8: Stateless Functional Components
&lt;/h3&gt;

&lt;p&gt;True React components are complex beings. They have a whole bunch of inherited features like lifecycle methods along with other additional methods that we create. &lt;/p&gt;

&lt;p&gt;Sometimes we simply don't need this complexity. For instance, our Header component is only used to render HTML to the DOM. It doesn't need to be anything more than an arrow function. &lt;/p&gt;

&lt;p&gt;This means we can convert it from a full React Component into a Stateless Functional Component:&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fs3-ap-southeast-2.amazonaws.com%2Fghost-blog-stef-ninja%2F2017%2F07%2Ffunctional_stateless_component-1499392930264.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%2Fs3-ap-southeast-2.amazonaws.com%2Fghost-blog-stef-ninja%2F2017%2F07%2Ffunctional_stateless_component-1499392930264.png" alt="Converting a React Component into a Functional Stateless Component"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h6&gt;
  
  
  Rule of thumb:
&lt;/h6&gt;


&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;if( component only uses render method ){
convert it to a stateless functional component
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;&lt;strong&gt;Further Reading:&lt;/strong&gt; This was only a short video so I was able to do some more reading about &lt;em&gt;Stateless Functional Components&lt;/em&gt; for the rest of the 30-minutes. Here are some of the good resources I found:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;a href="https://hackernoon.com/react-stateless-functional-components-nine-wins-you-might-have-overlooked-997b0d933dbc" rel="noopener noreferrer"&gt;React Stateless Functional Components: Nine Wins You Might Have Overlooked&lt;/a&gt; by &lt;a href="https://twitter.com/housecor" rel="noopener noreferrer"&gt;Cory House&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://medium.com/@joshblack/stateless-components-in-react-0-14-f9798f8b992d" rel="noopener noreferrer"&gt;Stateless Functional Components in React 0.14&lt;/a&gt; by &lt;a href="https://medium.com/@joshblack" rel="noopener noreferrer"&gt;Josh Black&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h6&gt;
  
  
  Today the app looks like:
&lt;/h6&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%2Fs3-ap-southeast-2.amazonaws.com%2Fghost-blog-stef-ninja%2F2017%2F07%2Fday_8-1499400482804.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%2Fs3-ap-southeast-2.amazonaws.com%2Fghost-blog-stef-ninja%2F2017%2F07%2Fday_8-1499400482804.png" alt="App on Day 8 of the React for Beginners Course"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Note: There were no visual changes from yesterday&lt;/p&gt;

&lt;p&gt;&lt;em&gt;[Video 8: Stateless Functional Components]&lt;/em&gt;&lt;/p&gt;
&lt;h3&gt;
  
  
  Day 9: Using React Router
&lt;/h3&gt;

&lt;p&gt;Today we explored the &lt;code&gt;React Router&lt;/code&gt; tool. It doesn't come as part of the React package but it is the industry standard for implementing routing within React applications.&lt;/p&gt;

&lt;p&gt;Our application routing will be handled by a simple component that has some if/else style logic built in. It calls the &lt;code&gt;Match&lt;/code&gt; and &lt;code&gt;Miss&lt;/code&gt; from &lt;code&gt;React Router&lt;/code&gt; to handle the heavy lifting.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Import { BrowserRouter, Match, Miss } from 'react-router';

const Root = () =&amp;gt; {
  return(
    &amp;lt;BrowserRouter&amp;gt;
      &amp;lt;div&amp;gt;
        &amp;lt;Match exactly pattern="/" component={StorePicker} /&amp;gt;
        &amp;lt;Match pattern="/store/:storeId" component={App} /&amp;gt;
        &amp;lt;Miss component={NotFound} /&amp;gt;
      &amp;lt;/div&amp;gt;
    &amp;lt;/BrowserRouter&amp;gt;
  )
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Note: This is using an outdated version of &lt;code&gt;React Router&lt;/code&gt;. The latest verison would look more like:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Import { Switch, Route } from 'react-router-dom';

const Root = () =&amp;gt; {
  return(
    &amp;lt;Switch&amp;gt;
        &amp;lt;Route exact path="/" component={StorePicker} /&amp;gt;
        &amp;lt;Route path="/store/:storeId" component={App} /&amp;gt;
        &amp;lt;Route component={NotFound} /&amp;gt;
    &amp;lt;/Switch&amp;gt;
  )
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The results can be seen below. The only other task from todays workshop was to create a &lt;code&gt;NotFound&lt;/code&gt; component that can display as a sudo 404 page.&lt;/p&gt;

&lt;h6&gt;
  
  
  Today the app looks like:
&lt;/h6&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%2Fs3-ap-southeast-2.amazonaws.com%2Fghost-blog-stef-ninja%2F2017%2F07%2Fday_9_progress-1499663936121.gif" 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%2Fs3-ap-southeast-2.amazonaws.com%2Fghost-blog-stef-ninja%2F2017%2F07%2Fday_9_progress-1499663936121.gif" alt="App on Day 9 of the React for Beginners Course"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;[Video 9: Routing with React Router]&lt;/em&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Day 10: Helper Functions
&lt;/h3&gt;

&lt;p&gt;Today was a short and sharp lesson about helper functions. These aren't React specific but is something that Wes Bos chooses to put into his Javascript applications.&lt;/p&gt;

&lt;p&gt;If a function is going to be used throughout the app but isn't important/big enough to warrant creating a module for it then putting it in the &lt;code&gt;helper.js&lt;/code&gt; file is a good idea. &lt;/p&gt;

&lt;p&gt;The project files were generated with a few helper functions that allow us to generate random Store names and format the price to display in a currency format nicely. &lt;/p&gt;

&lt;p&gt;Using these functions is as easy as importing the function &amp;amp; then calling it:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import { getFunName } from '../helpers';
...
&amp;lt;input type="text" required placeholder="Store Name" defaultValue={ getFunName() } /&amp;gt;
...
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h6&gt;
  
  
  Today the app looks like:
&lt;/h6&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%2Fs3-ap-southeast-2.amazonaws.com%2Fghost-blog-stef-ninja%2F2017%2F07%2Fday_10_random__storename-1499669184462.gif" 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%2Fs3-ap-southeast-2.amazonaws.com%2Fghost-blog-stef-ninja%2F2017%2F07%2Fday_10_random__storename-1499669184462.gif" alt="App on Day 10 of the React for Beginners Course"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;[Video 10: Helper and Utility Functions]&lt;/em&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Day 11: React Events
&lt;/h3&gt;

&lt;p&gt;A couple of things of note from today's lesson:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;React events are handled via the &lt;a href="https://facebook.github.io/react/docs/events.html" rel="noopener noreferrer"&gt;SyntheticEvent&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;React events are done in line.&lt;/li&gt;
&lt;li&gt;To get data out of an input we need to use a &lt;code&gt;function ref&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;render()&lt;/code&gt; is a method that is inherently bound to the component. &lt;/li&gt;
&lt;li&gt;When adding an additional/custom method do a component you need to explicitly bind it to the component so that we can use &lt;code&gt;this&lt;/code&gt; within it. &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;There are a few ways that you can bind custom methods to the component:&lt;/p&gt;

&lt;p&gt;You can reference them within the &lt;code&gt;constructor()&lt;/code&gt; e.g:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;class StorePicker extends React.Component {
  constructor(){
    super();
    this.goToStore = this.goToStore.bind(this);
  }

  goToStore() {
    //Custom method.
  }

  render() {
    //Standard method
  }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You can bind the method when it is being called by the &lt;code&gt;onSubmit&lt;/code&gt; event handler. e.g:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;render() {
    return(
      &amp;lt;form className="form" onSubmit={this.goToStore.bind(this)}&amp;gt;
        &amp;lt;input type="text" ref={(input) =&amp;gt; {this.storeInput = input}}/&amp;gt;
        &amp;lt;button type="submit"&amp;gt;Submit&amp;lt;/button&amp;gt;
      &amp;lt;/form&amp;gt;
    )
  }
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You can run an arrow function when the method is being called by the &lt;code&gt;onSubmit&lt;/code&gt; event handler. e.g:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;render() {
    return(
      &amp;lt;form className="form" onSubmit={(e) =&amp;gt; this.goToStore(e)}&amp;gt;
        &amp;lt;input type="text" ref={(input) =&amp;gt; {this.storeInput = input}}/&amp;gt;
        &amp;lt;button type="submit"&amp;gt;Submit&amp;lt;/button&amp;gt;
      &amp;lt;/form&amp;gt;
    )
  }
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;We didn't do to many app changes today but we put a &lt;code&gt;console.log()&lt;/code&gt; into the event handler so you can see the refs being passed through.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Note: This lesson sparked a lengthy discussion with my development team. Whilst, traditionally the constructor was used to initialise state, however, with the changes in JS we are able to initialise state directly as a class property. This reduces noise in the code as well as increases the performance. Added bonus: when using &lt;code&gt;create-react-app&lt;/code&gt; there is no need to worry about transpiling your code - it is already built in. You can read more about this here in &lt;a href="https://michalzalecki.com/react-components-and-class-properties/" rel="noopener noreferrer"&gt;React Components and Class Properties&lt;/a&gt; by &lt;a href="https://twitter.com/MichalZalecki" rel="noopener noreferrer"&gt;Michal Zalecki&lt;/a&gt;.&lt;/em&gt;&lt;/p&gt;

&lt;h6&gt;
  
  
  Today the app looks like:
&lt;/h6&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%2Fs3-ap-southeast-2.amazonaws.com%2Fghost-blog-stef-ninja%2F2017%2F07%2Fday12_consolelog_ref-1499841955473.gif" 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%2Fs3-ap-southeast-2.amazonaws.com%2Fghost-blog-stef-ninja%2F2017%2F07%2Fday12_consolelog_ref-1499841955473.gif" alt="App on Day 11 of the React for Beginners Course"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;[Video 11: Working with React Events]&lt;/em&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Day 12:
&lt;/h3&gt;

&lt;p&gt;Today we are finishing off the &lt;code&gt;GoToStore()&lt;/code&gt; method. We are already receiving in the data that we want to work with (from the input ref) and now we need to action that with a redirect.&lt;/p&gt;

&lt;p&gt;To do this we are using the &lt;code&gt;transitionTo&lt;/code&gt; method made available to us by &lt;code&gt;React Router&lt;/code&gt;. &lt;/p&gt;

&lt;p&gt;Because of the one-way data flow of React, we need to surface the router from the parent using &lt;a href="https://facebook.github.io/react/docs/context.html" rel="noopener noreferrer"&gt;contextTypes&lt;/a&gt;. This will make it available to our component. &lt;/p&gt;

&lt;p&gt;This is done by adding the following below our component on StorePicker.js:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;StorePicker.contextTypes = {
  router: React.PropTypes.object
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now that the router object is available to us all we need to do is call the &lt;code&gt;transitionTo()&lt;/code&gt; method in our &lt;code&gt;goToStore()&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;goToStore(event){
    event.preventDefault();
    const storeId = this.storeInput.value
    this.context.router.transitionTo(`/store/${storeId}`)
  }
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h6&gt;
  
  
  Today the app looks like:
&lt;/h6&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%2Fs3-ap-southeast-2.amazonaws.com%2Fghost-blog-stef-ninja%2F2017%2F07%2Fday12_transitionTo-1499843745265.gif" 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%2Fs3-ap-southeast-2.amazonaws.com%2Fghost-blog-stef-ninja%2F2017%2F07%2Fday12_transitionTo-1499843745265.gif" alt="App on Day 12 of the React for Beginners Course"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;[Video 12: All About React Router]&lt;/em&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Day 13: Introduction to State
&lt;/h3&gt;

&lt;p&gt;The video for today is titled 'Understanding State'. I'm going to dial that back and instead reference it as 'An Introduction to State'.&lt;/p&gt;

&lt;p&gt;Wes does mention that this is one of the videos that you should come back and watch on a regular basis until this concept has cemented itself for you.&lt;/p&gt;

&lt;p&gt;Below are my notes from the video:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;You store all of the application data within this master object called 'state'. Then if you want to change the page then you edit the 'state' and you let React handle the HTML for you. &lt;/li&gt;
&lt;li&gt;You edit the data. React edits the HTML for you.&lt;/li&gt;
&lt;li&gt;This is so powerful because once you change some of the data within the state object it is updated everywhere that state is called within your application. No need to worry about each implementation. &lt;/li&gt;
&lt;li&gt;React needs to know the initial state of the component. In ES6 components this is done within the constructor method by setting &lt;code&gt;this.state = {//state}&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;When updating your state you should take a copy of your current state, then update your state. This is done for performance and removing race conditions. 
eg.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;//Make a copy of the current state
const fishes = {...this.state.fishes};
//set time stamp
const timestamp = Date.now();
fishes[`fish-${timestamp}`] = fish;
//set state
this.setState({  fishes });
You can call a function from a child component via props.
e.g. in App.js:
&amp;lt;Inventory addFish={this.addFish} /&amp;gt;
then in Inventory.js we can pass this down via props:
&amp;lt;AddFishFor addFish={this.props.addFish} /&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;I'm not 100% across the intricacies of state but I'm going to leave it there for today. We will be going over this again in other videos.&lt;/p&gt;

&lt;h6&gt;
  
  
  Today the app looks like:
&lt;/h6&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%2Fs3-ap-southeast-2.amazonaws.com%2Fghost-blog-stef-ninja%2F2017%2F07%2Fday_13_submit_form-1499928966761.gif" 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%2Fs3-ap-southeast-2.amazonaws.com%2Fghost-blog-stef-ninja%2F2017%2F07%2Fday_13_submit_form-1499928966761.gif" alt="App on Day 13 of the React for Beginners Course"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;[Video 13: Understanding State]&lt;/em&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Day 14:
&lt;/h3&gt;

&lt;p&gt;Today we are focusing on putting a &lt;code&gt;Load Sample Fishes&lt;/code&gt; button onto the page. This is handy for quickly inserting some dummy data into the app so we can play around with the display of data in the next lesson. It also gives us a run through of loading state via &lt;code&gt;onClick()&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;ToDo List:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Create a button at the bottom of the Inventory Panel. &lt;/li&gt;
&lt;li&gt;Have the &lt;code&gt;onClick()&lt;/code&gt; call a function (&lt;code&gt;loadSamples()&lt;/code&gt;) that loads the object in &lt;code&gt;sample-fishes.js&lt;/code&gt; into the state.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;em&gt;Remember: State is on parent component &lt;code&gt;App&lt;/code&gt; so this is where the function needs to be. We need to pass this down to the child component via props (just like we did yesterday).&lt;/em&gt;&lt;/p&gt;

&lt;h6&gt;
  
  
  Today the app looks like:
&lt;/h6&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%2Fs3-ap-southeast-2.amazonaws.com%2Fghost-blog-stef-ninja%2F2017%2F07%2Fday14_loadSampleFishes-1499995248651.gif" 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%2Fs3-ap-southeast-2.amazonaws.com%2Fghost-blog-stef-ninja%2F2017%2F07%2Fday14_loadSampleFishes-1499995248651.gif" alt="App on Day 14 of the React for Beginners Course"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;[Video 14: Loading data into state onClick]&lt;/em&gt;&lt;/p&gt;




&lt;p&gt;Read more in this series: &lt;a href="https://stef.ninja/learning-react-week-1/" rel="noopener noreferrer"&gt;Week 1&lt;/a&gt;, &lt;a href="https://stef.ninja/learning-react-week-3/" rel="noopener noreferrer"&gt;Week 3&lt;/a&gt;, and &lt;a href="https://stef.ninja/learning-react-week-4/" rel="noopener noreferrer"&gt;Week 4&lt;/a&gt; &lt;strong&gt;Or&lt;/strong&gt; get the &lt;a href="https://reactforbeginners.com/" rel="noopener noreferrer"&gt;React for Beginners Course&lt;/a&gt; for yourself.&lt;/p&gt;

</description>
      <category>react</category>
      <category>javascript</category>
      <category>beginners</category>
    </item>
    <item>
      <title>Learning React - Week 1</title>
      <dc:creator>Stef Cola</dc:creator>
      <pubDate>Thu, 03 Aug 2017 04:24:50 +0000</pubDate>
      <link>https://dev.to/stefdotninja/learning-react---week-1</link>
      <guid>https://dev.to/stefdotninja/learning-react---week-1</guid>
      <description>&lt;p&gt;This article originally appeared on &lt;a href="https://stef.ninja/learning-react-week-1/" rel="noopener noreferrer"&gt;stef.ninja&lt;/a&gt; &lt;/p&gt;

&lt;p&gt;Today I'm starting a 30-minute challenge. I will commit 30 minutes a day to learning React via the &lt;a href="https://reactforbeginners.com/" rel="noopener noreferrer"&gt;React for Beginners&lt;/a&gt; Course written by Wes Bos.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Side Note: This is by far one of the best courses I have ever taken. Go and get it. Now.&lt;/em&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Day 1: Development Environment
&lt;/h3&gt;

&lt;p&gt;Setting up my development environment &amp;amp; going through the starter files. &lt;/p&gt;

&lt;p&gt;This included:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Ensuring my node version is up to date.&lt;/li&gt;
&lt;li&gt;That I have a ES6 syntax highlighter set up for my text editor (language-babel for atom).&lt;/li&gt;
&lt;li&gt;Installing the React Developer Tools extension into Chrome.&lt;/li&gt;
&lt;li&gt;Forking the starter file github project.&lt;/li&gt;
&lt;li&gt;Introduction to 'create-react-app'.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;We also went through an introduction to React Components and how the Props, State, &amp;amp; Context relate to these components.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;[Video 1: Introduction, Tooling &amp;amp; Editor Setup &amp;amp; 2: Thinking and Understanding React Components]&lt;/em&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Day 2: Components?
&lt;/h3&gt;

&lt;p&gt;Creating my first component. This included:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Creating a new 'StorePicker.js' file in the components directory.&lt;/li&gt;
&lt;li&gt;Importing the required dependencies&lt;/li&gt;
&lt;li&gt;Creating a class &amp;amp; returning JSX via &lt;code&gt;render()&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Importing the new component that I just created into the 'index.js' file.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;My files now look like this:&lt;br&gt;
&lt;/p&gt;

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

import React from 'react';
import { render } from 'react-dom';

import StorePicker from './components/StorePicker';

render(&amp;lt;StorePicker/&amp;gt;, document.querySelector('#main'));

components/StorePicker.js

import React from 'react';

class StorePicker extends React.Component{
  render() {
  return &amp;lt;p&amp;gt;Hello&amp;lt;/p&amp;gt;
  }
}

export default StorePicker;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This basic implementation seems pretty straight forward. I like the use of the es6 class and the basic requirements to always return at least one method (render() in this example).&lt;/p&gt;

&lt;p&gt;&lt;em&gt;[Video 3: Creating our First Components]&lt;/em&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Day 3: JSX
&lt;/h3&gt;

&lt;p&gt;The problem: Writing HTML in JavaScript sucks.&lt;br&gt;
The solution = JSX.&lt;/p&gt;

&lt;p&gt;The first step is setting up my text editor (Atom) to use the Emmet Plugin installed. This opens up access to Emmet shortcuts that make writing JSX approximately 948% easier.&lt;/p&gt;

&lt;p&gt;I used this Atom Editor Tutorial to run through a quick explanation of what Emmet is &amp;amp; how to use it: &lt;a href="https://www.youtube.com/watch?v=BQurqKG6nGY" rel="noopener noreferrer"&gt;https://www.youtube.com/watch?v=BQurqKG6nGY&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Quick note: the default Keystroke to expand the abbreviation in a JavaScript file is 'ctrl-e' not 'Tab' as used in HTML.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Back to learning the intricacies of JSX and how it works with React.&lt;/p&gt;

&lt;p&gt;Things to remember:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;To write a comment within JSX you need to use the format '{ /* Comment here */ }'. Don't put this at the top level as it will treat it as an element.&lt;/li&gt;
&lt;li&gt;'class' is a reserved word in Javascript so you need to use 'className'. Emmet helps with this.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;em&gt;[Video 4: Writing HTML with JSX]&lt;/em&gt;&lt;/p&gt;
&lt;h3&gt;
  
  
  Day 4: Styling in React
&lt;/h3&gt;

&lt;p&gt;There are plenty of options (and opinions) on how CSS should be loaded into React applications. A couple of these options are:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Reference a &lt;code&gt;style.css&lt;/code&gt; sheet in your &lt;code&gt;index.html&lt;/code&gt; document - much like standard HTML &amp;amp; CSS.&lt;/li&gt;
&lt;li&gt;import a style sheet into your &lt;code&gt;index.js&lt;/code&gt; document - hybrid option: &lt;code&gt;import './css/style.css';&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Create a CSS sheet for each component that only includes the CSS for that single component. This allows greater control over the component styling. e.g.  &lt;code&gt;import './css/store-picker.css';&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Inline styling using JSX formatting.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The method that you choose will depend on the project that you're working on, the current practices and the complexity of the project.&lt;/p&gt;

&lt;p&gt;This question sparked a big conversation in my office around why we use &lt;a href="https://github.com/styled-components/styled-components" rel="noopener noreferrer"&gt;'styled-components'&lt;/a&gt; and how this has impacted our development style. It was a great learning opportunity and I have found it is a handy concept to explore not just how but why we do things a certain way.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Usage Notes:&lt;/strong&gt;&lt;br&gt;
Our team just upgraded to using &lt;code&gt;prettier 0.34.0&lt;/code&gt; in-house. It beautifies the CSS in styled components now. Top notch addition.&lt;/p&gt;

&lt;p&gt;Also, the package &lt;code&gt;language-babel&lt;/code&gt; has proper syntax highlighting for styled-components in &lt;a href="https://atom.io/" rel="noopener noreferrer"&gt;Atom&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;The rest of today's 30 minutes was spent reading about styled-components:&lt;br&gt;
&lt;a href="https://github.com/styled-components/styled-components" rel="noopener noreferrer"&gt;https://github.com/styled-components/styled-components&lt;/a&gt;&lt;br&gt;
&lt;a href="https://www.smashingmagazine.com/2017/01/styled-components-enforcing-best-practices-component-based-systems/" rel="noopener noreferrer"&gt;https://www.smashingmagazine.com/2017/01/styled-components-enforcing-best-practices-component-based-systems/&lt;/a&gt;&lt;br&gt;
&lt;a href="https://medium.freecodecamp.org/a-5-minute-intro-to-styled-components-41f40eb7cd55" rel="noopener noreferrer"&gt;https://medium.freecodecamp.org/a-5-minute-intro-to-styled-components-41f40eb7cd55&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;If you don't want to read anything about styled-components take the time to watch this instead:&lt;br&gt;
&lt;a href="https://www.youtube.com/watch?v=bIK2NwoK9xk" rel="noopener noreferrer"&gt;https://www.youtube.com/watch?v=bIK2NwoK9xk&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;[Video 5: Loading CSS into our React Application]&lt;/em&gt;&lt;/p&gt;
&lt;h3&gt;
  
  
  Day 5: Transition to Linux
&lt;/h3&gt;

&lt;p&gt;Today I moved over from Windows to Linux (Ubuntu).&lt;/p&gt;

&lt;p&gt;This included setting up all of my tools and dependencies as well as getting the project code up to date with where I was on my Windows set up. &lt;/p&gt;

&lt;p&gt;Setting everything up again is what I focused on today. It was much quicker and smoother this time around.&lt;/p&gt;
&lt;h3&gt;
  
  
  Day 6: Components
&lt;/h3&gt;

&lt;p&gt;Today we delved further into the basic requirements of a component (class, render, return) and how these individual building blocks can be used to build a layout.&lt;/p&gt;

&lt;p&gt;With the following basic component structure we were able to map out our entire application layout:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import React from 'react';

class MyComponent extends React.Component {
     render() {
          return(
               &amp;lt;p&amp;gt;MyComponent Content&amp;lt;/p&amp;gt;
          )
     }
}

export default MyComponent;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;These components were then brought together via an 'app.js' component that returned a single div with all of the layout included. This was a great lesson.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;[Video 6: Creating our application layout with components]&lt;/em&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Day 7: Using Props
&lt;/h3&gt;

&lt;p&gt;Today we moved away from strictly static components and into injecting some dynamic content onto the page via props.&lt;/p&gt;

&lt;p&gt;We started off simple by changing the content of our subheading text in the 'Header.js' component to reference the tagline prop:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;h3 className="subheading"&amp;gt;{this.props.subheading}&amp;lt;/h3&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;We can then set a specific prop to be passed down and injected into the content like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;Header subheading="Those Fresh Feels" /&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;What is happening here is not only is the Header component being called but the subheading prop is being passed along with it. This means that any time we reference this component we can inject customised content. For instance:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;Header subheading="Those Fresh Feels" /&amp;gt;
&amp;lt;Header subheading="This is the second Header component" /&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Yay for components!&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%2Fs3-ap-southeast-2.amazonaws.com%2Fghost-blog-stef-ninja%2F2017%2F07%2Flearning_react_atom-1499324732994.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%2Fs3-ap-southeast-2.amazonaws.com%2Fghost-blog-stef-ninja%2F2017%2F07%2Flearning_react_atom-1499324732994.png" alt="React for Beginners - Starter Files"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;[Video 7: Passing Dynamic data with props]&lt;/em&gt;&lt;/p&gt;




&lt;p&gt;After the first week of learning my project looks like this:&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fs3-ap-southeast-2.amazonaws.com%2Fghost-blog-stef-ninja%2F2017%2F07%2Flearning_react-1499324570788.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%2Fs3-ap-southeast-2.amazonaws.com%2Fghost-blog-stef-ninja%2F2017%2F07%2Flearning_react-1499324570788.png" alt="Learning React with React for Beginners by Wes Bos - Week 1 Progress"&gt;&lt;/a&gt;&lt;/p&gt;




&lt;p&gt;Read more in this series: &lt;a href="https://stef.ninja/learning-react-week-2/" rel="noopener noreferrer"&gt;Week 2&lt;/a&gt;, &lt;a href="https://stef.ninja/learning-react-week-3/" rel="noopener noreferrer"&gt;Week 3&lt;/a&gt;, and &lt;a href="https://stef.ninja/learning-react-week-4/" rel="noopener noreferrer"&gt;Week 4&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Get the &lt;a href="https://reactforbeginners.com/" rel="noopener noreferrer"&gt;React for Beginners Course&lt;/a&gt; for yourself.&lt;/p&gt;

</description>
      <category>react</category>
      <category>javascript</category>
      <category>learning</category>
      <category>beginners</category>
    </item>
    <item>
      <title>Hi, I'm Stef</title>
      <dc:creator>Stef Cola</dc:creator>
      <pubDate>Mon, 10 Jul 2017 05:50:01 +0000</pubDate>
      <link>https://dev.to/stefdotninja/hi-im-stef</link>
      <guid>https://dev.to/stefdotninja/hi-im-stef</guid>
      <description>&lt;p&gt;I am currently transitioning from a project manager position into a full stack developer role (and I am PUMPED). &lt;/p&gt;

&lt;p&gt;I completed my Diploma of Website Design &amp;amp; Development earlier this year and am looking forward to putting my skills to use in my new role. I have a mega supportive team that point me in the right direction to continue my learning journey. &lt;/p&gt;

&lt;p&gt;You can find me on Twitter as &lt;a href="https://twitter.com/stefdotninja" rel="noopener noreferrer"&gt;@stefdotninja&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I live in Bendigo, Australia.&lt;/p&gt;

&lt;p&gt;I am currently learning more about React.&lt;/p&gt;

&lt;p&gt;Nice to meet you.&lt;/p&gt;

</description>
      <category>introduction</category>
    </item>
  </channel>
</rss>
