<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[React Paths - Medium]]></title>
        <description><![CDATA[Blog for all things React from flocks at https://secureend.com. Contact us for react work - Medium]]></description>
        <link>https://medium.com/react-paths?source=rss----55750d1fca6a---4</link>
        <image>
            <url>https://cdn-images-1.medium.com/proxy/1*TGH72Nnw24QL3iV9IOm4VA.png</url>
            <title>React Paths - Medium</title>
            <link>https://medium.com/react-paths?source=rss----55750d1fca6a---4</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 17 Nov 2026 15:04:54 GMT</lastBuildDate>
        <atom:link href="https://medium.com/feed/react-paths" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Understanding SVG ViewBox]]></title>
            <link>https://medium.com/react-paths/understanding-svg-viewbox-65bfc16c1b70?source=rss----55750d1fca6a---4</link>
            <guid isPermaLink="false">https://medium.com/p/65bfc16c1b70</guid>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[svg]]></category>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[reactjs]]></category>
            <category><![CDATA[html]]></category>
            <dc:creator><![CDATA[Parul Aditya]]></dc:creator>
            <pubDate>Tue, 27 Oct 2020 10:32:46 GMT</pubDate>
            <atom:updated>2020-10-28T08:02:12.335Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*yZx_gPhCaL5hlqae" /><figcaption>Photo by <a href="https://unsplash.com/@pankajpatel?utm_source=medium&amp;utm_medium=referral">Pankaj Patel</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>While fully understanding how SVGs work is quite hard, and can be considered a “rare” skill, it can prove rather useful. ViewBox can prove to be highly confusing for a beginner, so here&#39;s a basic guide where I cover the very basics of a viewBox.</p><h3>View Box</h3><p>The viewBox is what makes SVGs scalable. We can make our SVG any size we like, and everything will scale naturally, since the elements within the SVG are relative to it. The viewBox can be thought of as a telescope; it zooms and pans to the dimensions we give it. It has 4 attributes -</p><p>min-x, min-y, width and height.</p><p>The position of the viewBox can be set with the first 2 attributes. They are the coordinates from where the viewBox starts.</p><p>The width and height attributes are responsible for the “zoom” feature. If these values are same as the height and width of the SVG, nothing will appear to be changed.</p><p>However if these are larger than the SVG’s dimensions, it’ll create a “zoomed-out” effect, and vice-versa if they are smaller. To make it clearer lets have a look at this code:</p><pre>&lt;svg<br>      style=&quot;border: 1px solid black;&quot;<br>      height=&quot;300&quot;<br>      width=&quot;300&quot;<br>      viewBox=&quot;0 0 300 300&quot;<br>      xmlns=&quot;&lt;http://www.w3.org/2000/svg&gt;&quot;<br>    &gt;<br>   <br>      &lt;rect x=&quot;0&quot; y=&quot;0&quot; width=&quot;100%&quot; height=&quot;100%&quot; fill=&quot;red&quot; /&gt;      <br>      &lt;circle cx=&quot;50%&quot; cy=&quot;50%&quot; r=&quot;10&quot; fill=&quot;black&quot; /&gt;<br>    <br>&lt;/svg&gt;</pre><p><strong>The dimensions of the SVG are </strong><strong>300*300, and it has a rectangle and a circle within.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/317/1*cCiodD5XhUP0fRO-O1WElg.png" /></figure><p>As the dimensions of the SVG and the dimensions of the viewBox are the same, the SVG appears the same.</p><p>This is how the SVG would appear without a viewBox.</p><h4><strong>About the shapes:</strong></h4><blockquote>The rectangle starts from 0,0 of the SVG, and as the dimensions are in percentage, it covers the entire SVG.</blockquote><blockquote>The circle starts from 50%, 50%- which is the center of the SVG rectangle, with a set radius of 10px</blockquote><h3>Changing the height and width</h3><h4>Zooming-in:</h4><p>To create a “zoomed-in” effect, all we need to do is change the last two attributes- height and width. If their values are less than the SVG’s; which in our case are 300*300, the viewBox works like a telescope or a magnifying glass, it shows us lesser area, but magnified.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/314/1*CPOt-uQ4YrEKTWKXfXZbGw.png" /></figure><p>Now if we change the viewBox coordinates to 0 0 100 100 , we see that the circle appears to be bigger. Relative to the center of the SVG, the viewport now shows us 100*100. As the circles center was in percentage, it still remains in the center.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/318/1*FOJKJyi7cB3zyzybS3JhNA.png" /></figure><p>Similarly we can change it to 0 0 50 50.</p><p>If we use larger dimensions here, instead of zooming-in, it’ll be zoomed out.</p><pre>&lt;svg</pre><pre>style=&quot;border: 1px solid black;&quot;</pre><pre>height=&quot;300&quot;</pre><pre>width=&quot;300&quot;</pre><pre>viewBox=&quot;0 0 100 100&quot;</pre><pre>xmlns=&quot;&lt;http://www.w3.org/2000/svg&gt;&quot;</pre><pre>&gt;</pre><pre>&lt;rect x=&quot;0&quot; y=&quot;0&quot; width=&quot;100%&quot; height=&quot;100%&quot; fill=&quot;red&quot; /&gt;</pre><pre>&lt;circle cx=&quot;50%&quot; cy=&quot;50%&quot; r=&quot;10&quot; fill=&quot;black&quot; /&gt;</pre><pre>&lt;/svg&gt;</pre><h4>Zooming-out:</h4><p>Similarly, if the height and width of the viewBox is more than that of the SVG, it creates a “zoomed-out” effect. This is because while the SVG is 300*300 , increasing the values of the viewBox means it shows us more area than that, which makes the SVG look smaller.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/314/1*9z-_EoO3g_nNkniSVVHlTg.png" /></figure><p>In case of viewBox = &quot;0 0 1000 1000&quot; , the visible area is now scaled up to 1000px*1000px.</p><p>As the &lt;rect&gt; element’s dimensions were in percentage, it remains unchanged visually, but the circle is visibly smaller.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=65bfc16c1b70" width="1" height="1" alt=""><hr><p><a href="https://medium.com/react-paths/understanding-svg-viewbox-65bfc16c1b70">Understanding SVG ViewBox</a> was originally published in <a href="https://medium.com/react-paths">React Paths</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to get HTTPS working in localhost development environment]]></title>
            <link>https://medium.com/react-paths/how-to-get-https-working-in-localhost-development-environment-f17de34af046?source=rss----55750d1fca6a---4</link>
            <guid isPermaLink="false">https://medium.com/p/f17de34af046</guid>
            <category><![CDATA[ssl]]></category>
            <category><![CDATA[technology]]></category>
            <category><![CDATA[servers]]></category>
            <category><![CDATA[tech]]></category>
            <category><![CDATA[https]]></category>
            <dc:creator><![CDATA[Admin]]></dc:creator>
            <pubDate>Wed, 25 Jul 2018 06:23:41 GMT</pubDate>
            <atom:updated>2018-08-21T09:35:39.526Z</atom:updated>
            <content:encoded><![CDATA[<h4>Become a certificate authority (CA) like Let’s Encrypt, Verisign etc.. Issue yourself certificates for local development domains!</h4><p>If you follow the steps mentioned in many blogs that tell you to create your ssl certificate. Then stop as the advice became outdated when Chrome fixed this — “<em>Support for commonName matching in certificates</em>”.</p><p>So, how do you remove the “<em>your connection is not private</em>” error in the browser when you visit a localhost domain?</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*RCS6S0akmoANEG3YfSY5pA.png" /><figcaption><em>Your connection is not private</em></figcaption></figure><h3>3 steps to become a Certificate Authority</h3><p>We will make a rootSSL certificate that will be used to sign any number of certificates for any number of local hosted domains. So open your terminal and let’s get started.</p><ol><li><strong>Create a private key </strong><strong>rootSSL.key</strong></li></ol><p>Type below text and provide a pass phrase when asked for</p><pre>openssl genrsa -des3 -out rootSSL.key 2048</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5iIo6VTkC-lVV9LDVKQ1Mg.png" /></figure><p>2. <strong>Create certificate </strong><strong>rootSSL.pem file using private key </strong><strong>roorSSL.key</strong></p><p>The validity is 1024 days which you can set to any number of days and I recommend the longer the better. You will be asked a number of questions which you need to answer as shown in the screenshot below.</p><pre>openssl req -x509 -new -nodes -key rootSSL.key -sha256 -days 1024 -out rootSSL.pem</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*dwAOh7magNM5r5TyM08kUQ.png" /></figure><p><strong>3. Trust the Certificate Authority CA on your local development machine</strong></p><p><strong>Mac / Windows / Ubuntu</strong></p><h4><strong>Mac</strong></h4><p>Open Key chain App<br>Go to File &gt; Import Items and select <strong>rootSSL.pem</strong> file to key chain and you will see it like this.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/879/1*z17_3dnCVS3e2P6Ck_ZQqQ.png" /><figcaption><strong>Trust the root SSL certificate on Mac</strong></figcaption></figure><p>Double Click on imported file and go to <strong>trust section</strong> and change “<em>When using this certificate:” </em>choose <strong>Trust Always</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1010/1*YC2ZyJ9Wk3-9KJqV3ASSTA.png" /><figcaption><strong>Trust the root SSL certificate on Mac</strong></figcaption></figure><h4>Linux (Debian / Ubuntu)</h4><p>To install root SSL certificate in Ubuntu, open your terminal and do the following.</p><pre>sudo mkdir /usr/local/share/ca-certificates/extra</pre><pre>sudo cp rootSSL.pem \<br>/usr/local/share/ca-certificates/extra/rootSSL.crt</pre><pre>sudo update-ca-certificates</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/927/1*A0md4TUHv3U50rGbou6_WA.png" /><figcaption><strong>Trust the root SSL certificate on Debian / Ubuntu</strong></figcaption></figure><h4>Windows 10</h4><p>To install root SSL certificate in windows 10, use Microsoft Management Console(<strong>MMC</strong>)</p><blockquote><strong>Step 1: </strong>Click <strong>Start</strong> &gt; <strong>Run</strong></blockquote><blockquote><strong>Step 2</strong>: Enter <strong>MMC</strong> to open Microsoft Management Console<strong>.</strong></blockquote><blockquote><strong>Step3</strong>: Go to File &gt; Add/Remove Snap-in</blockquote><blockquote><strong>Step 4</strong>: Click Certificates, and select Add</blockquote><blockquote><strong>Step 5</strong>: Select Computer Account<strong>,</strong> and click Next</blockquote><blockquote><strong>Step 6</strong>: Select Local Computer and click Finish</blockquote><blockquote><strong>Step 7: </strong>Click OK to go back to main MMC console window.</blockquote><blockquote><strong>Step 8:</strong>Double-click Certificates (local computer)<strong> </strong>to expand its view.</blockquote><blockquote><strong>Step 9:</strong>Right-click Certificates under Trusted Root Certification Authorities and select All Tasks then Import</blockquote><blockquote><strong>Step 10:</strong>Complete the wizard to import the chain certificate. Browse to locate the chain certificate to be imported or rootSSL.pem file to import</blockquote><blockquote><strong>Step 11: </strong>Select Place all certificates in the following store and select the Trusted Root Certification Authorities store.Click Next; then click Finish to complete the wizard.</blockquote><p>Once the “import was successful” then you can locate your installed certificate authority in certificate pane.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/681/1*6ORkIAUKz2iOZsNtDBO82Q.gif" /><figcaption><strong>Trust the root SSL certificate on Windows 10</strong></figcaption></figure><p>Now you are a trusted Certificate Authority on your development machine. Follow the Step 3 on as many machines / servers that you need to. It’s a one time work for next 1024 days!</p><h3>2 steps to issue Certificate for a local Domain</h3><p>We assume that your local domain is “<strong><em>demo.local</em>” </strong>so let’s go ahead and issue our first ssl certificate!</p><ol><li><strong>Create a private key </strong><strong>demo.local.key</strong></li></ol><blockquote>👉 <strong>NOTE WINDOWS USERS</strong> . Replace \ with ^ for multi line support in cmd.exe shell</blockquote><pre>openssl req \<br> -new -sha256 -nodes \<br> -out <strong>demo.local.csr</strong> \<br> -newkey rsa:2048 -keyout <strong>demo.local.key</strong> \<br> -subj &quot;/<a href="/service/mailto:C=IN/ST=State/L=City/O=Organization/OU=OrganizationUnit/CN=demo.local/emailAddress=demo@example.com">C=<strong>IN</strong>/ST=<strong>State</strong>/L=<strong>City</strong>/O=<strong>Organization</strong>/OU=<strong>OrganizationUnit</strong>/CN=<strong>demo</strong>/emailAddress=<strong>demo@example.com</strong></a>&quot;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*MY5oagjhqokpP5RDZkOoOg.png" /></figure><p><strong>2. Create new certificate using rootSSL certificate</strong></p><blockquote>👉<strong> NOTE WINDOWS USERS</strong> . Replace <em>\</em> with <em>^</em> for multi line support in cmd.exe shell</blockquote><pre>openssl x509 \<br> -req \<br> -in <strong>demo.local.csr</strong> \<br> -CA <strong>rootSSL.pem</strong> -CAkey <strong>rootSSL.key</strong> -CAcreateserial \<br> -out <strong>demo.local.crt</strong> \<br> -days 500 \<br> -sha256 \<br> -extfile &lt;(echo &quot; \<br>    authorityKeyIdentifier=keyid,issuer\n \<br>    basicConstraints=CA:FALSE\n \<br>    keyUsage = digitalSignature, nonRepudiation, keyEncipherment, dataEncipherment\n \<br>    <strong>subjectAltName=DNS:demo.local</strong> \<br>   &quot;)</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*pfCd-vI5oelllXPwS3WMbg.png" /></figure><p><strong>Final step — Use your SSL certificate with the server</strong></p><p>Now you have to secure your localhost domain for which the certificate has been created. This will depend on the Webserver that you are using. But basically it means copying the demo.local.crt anddemo.local.key where your server can use them.</p><p>For example, for nginx, edit the virtual host file for demo.local and add the following:</p><pre>ssl  on; <br>ssl_certificate    /etc/nginx/ssl/demo.local.crt; <br>ssl_certificate_key    /etc/nginx/ssl/demo.local.key;</pre><p>Or For NodeJS HTTPs Server</p><pre><em>const</em> https = require(&quot;https&quot;);<br>const fs = require(&quot;fs&quot;);</pre><pre>const options = {<br> hostname: &quot;demo.local&quot;,<br> <strong>key: fs.readFileSync(&quot;demo.local.key&quot;),<br> cert: fs.readFileSync(&quot;demo.local.crt&quot;)</strong><br>};</pre><pre>https<br> .createServer(options, (req, res) =&gt; {<br>  res.writeHead(200);<br>  res.end(&quot;hello world\n&quot;);<br> })<br> .listen(8888);</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/796/1*afUnClEOkCRqbPR_Hih7wg.png" /><figcaption>All Green and Good now!</figcaption></figure><p>Restart the server and hit the domain. All should be green &amp; good now.</p><p>For step by step “<em>How to Use your SSL certificate with nginx, Apache or Nodejs server,</em>” there is a 2nd post coming.</p><p><strong>If you need any help in setting this up drop me a message at team@secureend.com.</strong></p><blockquote><em>If you enjoyed this post, don’t forget to leave claps and follow us for more interesting articles. If you need any react or react native work done, contact us over at </em><a href="https://secureend.com/#contact"><em>https://secureend.com</em></a><em> or on our </em><a href="https://twitter.com/SecureEnd"><em>twitter</em></a><em> or </em><a href="https://facebook.com/SecureEnd"><em>facebook</em></a><em>.</em></blockquote><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f17de34af046" width="1" height="1" alt=""><hr><p><a href="https://medium.com/react-paths/how-to-get-https-working-in-localhost-development-environment-f17de34af046">How to get HTTPS working in localhost development environment</a> was originally published in <a href="https://medium.com/react-paths">React Paths</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[React Myths or Facts?]]></title>
            <link>https://medium.com/react-paths/react-myths-or-facts-7d82aef51b01?source=rss----55750d1fca6a---4</link>
            <guid isPermaLink="false">https://medium.com/p/7d82aef51b01</guid>
            <category><![CDATA[react]]></category>
            <category><![CDATA[javascript]]></category>
            <dc:creator><![CDATA[Buns]]></dc:creator>
            <pubDate>Thu, 19 Jul 2018 07:59:39 GMT</pubDate>
            <atom:updated>2018-07-19T07:59:38.692Z</atom:updated>
            <content:encoded><![CDATA[<p>React with Script tag? Simple Css Classes? No webPack? On any existing Page? Copy the code at end and let’s check these out! Myths or Facts?</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*64TYzBV8bHzKZzan" /><figcaption>“sailboat on calm body of water under white sky at daytime” by <a href="https://unsplash.com/@loading82?utm_source=medium&amp;utm_medium=referral">Hugo Kerr</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>There is a persistent buzz that React is very complicated to get started with. That it needs a huge setup and has many moving parts to setup before you can do a “hello world”.</p><p>That is not exactly true but still the <strong>perception has grown</strong> because almost all blog posts and training materials start with a boilerplate and if you check what it contains then it’s a huge number of technologies to understand.</p><h3>Dan Abramov on Twitter</h3><p>Maybe we should do React MythBusters. Episode 1: React can&#39;t be used as a &amp;lt;script&amp;gt; tag (myth) Episode 2: If you want JSX, you need webpack (myth) Episode 3: You need to use CSS-in-JS with React (myth) Episode 4: React isn&#39;t friendly for accessibility (myth) ...</p><p><a href="https://medium.com/u/a3a8af6addc1">Dan Abramov</a> has been very persistent in his tweets to change this perception.</p><p>His latest got me thinking and resulted in this post to test what’s what.</p><blockquote>I have been training people from jQuery land to React for quite some time well before CRA &amp; Webpack got the mind share. If you need any Reactjs projects or need training for your team, get in touch.</blockquote><p><strong>Before you start —</strong></p><ol><li>Copy the code at end into any .html file and save it anywhere.</li><li>Then right click and open this file in any browser.</li><li>Open the same html file in any text editor</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*gysDfIoRrC79rC9CIw5Rbw.png" /><figcaption>The example file</figcaption></figure><p>Read on and play with code to test.</p><h3>1. You can’t use React with a &lt;script&gt; tag only — Myth</h3><blockquote>Well…Yes — you can! And that’s a <strong>Fact</strong></blockquote><p>To use React, you just need to add the two script tags in start and your react code at bottom and you are ready to go.</p><pre><strong>&lt;!-- Add these two script tag on top of your page --&gt;</strong><br>&lt;script src=&quot;https://unpkg.com/react@16/umd/react.development.js&quot; crossorigin&gt;&lt;/script&gt;<br>&lt;script src=&quot;https://unpkg.com/react-dom@16/umd/react-dom.development.js&quot; crossorigin&gt;&lt;/script&gt;</pre><pre>&lt;!-- Add this in bottom --&gt;</pre><pre><strong>&lt;!-- Your React component --&gt;</strong><br>&lt;script src=&quot;./path/to/my_react_code.js&quot;&gt;&lt;/script&gt;</pre><p><strong><em>If you want use JSX </em></strong>then you have to add another script tag that will <strong><em>load Babel in browser and compile JSX into the javascript</em></strong> which will then be used. It’s a HUGE NO-NO for production and only good for development. See section “<strong><em>Production ready</em></strong> ” of <strong>Point 3</strong> below.</p><pre>&lt;!-- Add these three script tag on top of your page --&gt;</pre><pre>&lt;script src=&quot;https://unpkg.com/react@16/umd/react.development.js&quot; crossorigin&gt;&lt;/script&gt;</pre><pre>&lt;script src=&quot;https://unpkg.com/react-dom@16/umd/react-dom.development.js&quot; crossorigin&gt;&lt;/script&gt;</pre><pre><strong>&lt;script src=&quot;https://unpkg.com/babel-standalone@6/babel.min.js&quot; crossorigin&gt;&lt;/script&gt;</strong></pre><pre>&lt;!-- Add this in bottom --&gt;</pre><pre>&lt;!-- Your React component <strong>NOTE: type attribute</strong>--&gt;<br>&lt;script <strong>type=&quot;text/babel&quot;</strong> src=&quot;./path/to/my_react_code.js&quot;&gt;&lt;/script&gt;</pre><h3>2. You HAVE to use JSX — Myth</h3><blockquote>Well…No You don’t need to use JSX. And that’s a <strong>Fact</strong></blockquote><p>You can use pure javascript representation to replace JSX syntax. It will be a little more verbose but pure JS.</p><p>In the example code you have both type of buttons, Non JSX and JSX.</p><p><strong>Non JSX Version</strong></p><pre>class LikeButton extends React.Component {<br> render() {<br>  return React.createElement(<br>   &quot;button&quot;,<br>   {<br>    className: &quot;blueButton&quot;,<br>    onClick: () =&gt; alert(&quot;Do your stuff here!&quot;)<br>   },<br>   &quot;Like no JSX&quot;<br>  );<br> }<br>}</pre><p><strong>Vs JSX version</strong></p><pre>class LikeButtonJsx extends React.Component {<br> render() {<br>  return (<br>   &lt;button<br>    className=&quot;blueButton&quot;<br>    onClick={() =&gt; alert(&quot;Do your stuff here!&quot;)}<br>   &gt;<br>    Like JSX<br>   &lt;/button&gt;<br>  );<br> }<br>}</pre><h3>3. You need Webpack for JSX — Myth</h3><blockquote>Well... No — Works very well without Webpack. And that’s a <strong>Fact</strong></blockquote><p><strong>Babel is your friend!! <br></strong>Babel will allow you to use the latest stuff in Javascript land. It will also convert JSX (which is not Javascript) into plain Javascript.</p><p><strong><em>Development only : works with &lt;script&gt; tag<br></em></strong>As mentioned section above, you can add a script tag that loads Babel in browser which converts JSX to Javascript in runtime.</p><p><strong><em>Production ready</em></strong><em> : </em><strong><em>works with nodejs</em></strong><br>For this you just need <a href="https://nodejs.org/en/">nodeJS</a> on your machine.</p><p>Open a terminal window. Change directory to the project directory and run -</p><pre>cd /to/proj/dir<br>npm init -y<br>npm install babel-cli@6 babel-preset-react-app@3</pre><p>Make a sub directory in the project folder say src (you can name it any name). Then run the command below</p><pre>npx babel --watch src --out-dir . --presets react-app/prod</pre><blockquote>This will start a log running process that will keep a watch over all the javascript files for change and whenever any file changes it will compile it and copy the compiled file to the <em>src</em> directory.</blockquote><blockquote>NOTE: Don’t close the terminal! The above command will work till terminal is open.</blockquote><p>Now you have to point the script tag in browser to the file that gets compiled and copied in src folder. So the code in browser will now look like:</p><pre><strong>&lt;!-- Add these two script tag on top of your page --&gt;</strong><br>&lt;script src=&quot;https://unpkg.com/react@16/umd/react.development.js&quot; crossorigin&gt;&lt;/script&gt;<br>&lt;script src=&quot;https://unpkg.com/react-dom@16/umd/react-dom.development.js&quot; crossorigin&gt;&lt;/script&gt;</pre><pre>&lt;!-- Add this in bottom --&gt;</pre><pre><strong>&lt;!-- ***** Your React component now Points to SRC directory --&gt;</strong><br>&lt;script src=&quot;./src/my_react_code.js&quot;&gt;&lt;/script&gt;</pre><h3>4. You need CSS-in-JS with React — Myth</h3><blockquote>Well...No — You really don’t. And that’s a <strong>Fact</strong></blockquote><p>As finally, React renders to DOM, you can add normal css classes of your own or from bootstrap etc. for styling. Actually adding css as object is a totally different concern that somehow got involved in React.</p><p><strong>Css</strong></p><pre><strong>.blueButton</strong> { <br>   background-color:blue;<br>}</pre><p><strong>Non JSX Version</strong></p><pre>class LikeButton extends React.Component {<br> render() {<br>  return React.createElement(<br>   &quot;button&quot;,<br>   {<br>    <strong>className: &quot;blueButton&quot;,</strong><br>    onClick: () =&gt; alert(&quot;Do your stuff here!&quot;)<br>   },<br>   &quot;Like no JSX&quot;<br>  );<br> }<br>}</pre><p><strong>Vs JSX version</strong></p><pre>class LikeButtonJsx extends React.Component {<br> render() {<br>  return (<br>   &lt;button<br>    <strong>className=&quot;blueButton&quot;</strong><br>    onClick={() =&gt; alert(&quot;Do your stuff here!&quot;)}<br>   &gt;<br>    Like JSX<br>   &lt;/button&gt;<br>  );<br> }<br>}</pre><h3>5. You can’t add React in existing Project — Myth</h3><blockquote>Well…Yes you can! And that’s a <strong>Fact</strong></blockquote><p>The basic concept of react is that it makes changes to a node in DOM. For example you can add react component to any node on the page and it will work fine.</p><p>In the example file, there are only two &lt;div&gt; tags that are used by React, rest whole page can be used by any other library like jQuery etc.</p><h3>6. You can’t add React in multiple nodes — Myth</h3><blockquote>Well…Yes you can! And that’s a <strong>Fact</strong></blockquote><p>In the example file, there are two &lt;div&gt; tags in which react is rendering two different components — one NON-JSX other JSX. You could render same component at multiple places also.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/97449f77385181d92e748ab2ccd830a2/href">https://medium.com/media/97449f77385181d92e748ab2ccd830a2/href</a></iframe><blockquote>If you enjoyed this post, don’t forget to leave claps and follow us for more interesting articles. If you need any react or react native work done, contact us over at <a href="https://secureend.com/">https://secureend.com</a> or on our <a href="https://twitter.com/SecureEnd">twitter</a> or <a href="https://facebook.com/SecureEnd">facebook</a>.</blockquote><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7d82aef51b01" width="1" height="1" alt=""><hr><p><a href="https://medium.com/react-paths/react-myths-or-facts-7d82aef51b01">React Myths or Facts?</a> was originally published in <a href="https://medium.com/react-paths">React Paths</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Upgrade React Native project to 0.56]]></title>
            <link>https://medium.com/react-paths/upgrade-react-native-project-to-0-56-7ce206566afd?source=rss----55750d1fca6a---4</link>
            <guid isPermaLink="false">https://medium.com/p/7ce206566afd</guid>
            <category><![CDATA[react-native]]></category>
            <category><![CDATA[react]]></category>
            <dc:creator><![CDATA[Admin]]></dc:creator>
            <pubDate>Wed, 11 Jul 2018 12:28:20 GMT</pubDate>
            <atom:updated>2018-07-16T05:02:59.011Z</atom:updated>
            <content:encoded><![CDATA[<h3>5 steps to upgrade React Native project to 0.56</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*Uf5xYoxyYTll7f76" /><figcaption>“Upgrade”</figcaption></figure><p>The current release of React Native is a biggish change. It now targets Android version 26 as per the <a href="https://android-developers.googleblog.com/2017/12/improving-app-security-and-performance.html">requirements for google play store</a> along with Node 8, iOS 9 the oldest iOS version etc.</p><p>There is an official way but steps below work cleaner for me.</p><h4>UPDATE : WARNING WINDOWS 10 USERS</h4><blockquote>It looks like there is issue in metro on windows 10. I don’t have a windows machine to check so please follow this issue <a href="https://github.com/facebook/react-native/issues/20015">https://github.com/facebook/react-native/issues/2005</a> and read this comment <a href="https://github.com/facebook/react-native/issues/20015#issuecomment-404128356">https://github.com/facebook/react-native/issues/20015#issuecomment-404128356</a> . <strong>This looks fixed now.</strong><br>Another Issue <a href="https://github.com/facebook/react-native/issues/19953">https://github.com/facebook/react-native/issues/19953</a> “Unable to resolve module AccessibilityInfo”<br>I will keep this notice till issues are resolved.</blockquote><h3>The Clean Way</h3><ol><li>Delete the android &amp; ios directories</li><li>Edit the package.json file and update the highlighted lines ‘<strong>react-native</strong>’ and ‘<strong>babel-preset-react-native</strong>’</li></ol><pre>{<br> &quot;name&quot;: &quot;AwesomeProject&quot;,<br> &quot;version&quot;: &quot;0.0.1&quot;,<br> &quot;private&quot;: true,<br> &quot;scripts&quot;: {<br>  &quot;start&quot;: &quot;node node_modules/react-native/local-cli/cli.js start&quot;,<br>  &quot;test&quot;: &quot;jest&quot;<br> },<br> &quot;dependencies&quot;: {<br>  &quot;react&quot;: &quot;16.3.1&quot;,<br>  <strong>&quot;react-native&quot;: &quot;^0.56.0&quot;,</strong><br>  &quot;react-native-firebase&quot;: &quot;^4.3.0&quot;<br> },<br> &quot;devDependencies&quot;: {<br>  &quot;babel-jest&quot;: &quot;23.2.0&quot;,<br>  <strong>&quot;babel-preset-react-native&quot;: &quot;^5.0.2&quot;,</strong><br>  &quot;jest&quot;: &quot;23.2.0&quot;,<br>  &quot;react-test-renderer&quot;: &quot;16.3.1&quot;<br> },<br> &quot;jest&quot;: {<br>  &quot;preset&quot;: &quot;react-native&quot;<br> }<br>}</pre><p>3. Run npm install or yarn to update the packages</p><h4>For Android you have to make changes in AndroidStudio to target Android 26</h4><p>4 (a). Start <strong>AndroidStudio</strong> &gt; select <strong>Preferences</strong> &gt; select ‘<strong>SDK Tools</strong>’ tab &gt; check <strong><em>Android SDK Tools version 26.x.x</em></strong> &gt; click <strong><em>Apply</em></strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Ej1wpfEO5QkVC-Bx3Txq2Q.png" /></figure><p>4 (b). Next select ‘<strong>SDK Platforms</strong>’ tab &gt; open <strong><em>Android 8.0 (Oreo)</em></strong> &gt; check the Highlighted option &gt; click <strong><em>Apply</em></strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*uGL1ZSt29eARkZBbX7hYoQ.png" /></figure><p>5. Finally Run react-native upgrade to re-create the android &amp; iOS directories again with new updated sdks</p><p>And you are now ready to compile again.</p><p>P.S. If you get this error “<em>Metro bundler has encountered an internal error</em>” then just close Metro Bundler terminal window and re-run again.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7ce206566afd" width="1" height="1" alt=""><hr><p><a href="https://medium.com/react-paths/upgrade-react-native-project-to-0-56-7ce206566afd">Upgrade React Native project to 0.56</a> was originally published in <a href="https://medium.com/react-paths">React Paths</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[So What is Compose again?]]></title>
            <link>https://medium.com/react-paths/so-what-is-compose-again-de44de41a0a?source=rss----55750d1fca6a---4</link>
            <guid isPermaLink="false">https://medium.com/p/de44de41a0a</guid>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[functional-programming]]></category>
            <dc:creator><![CDATA[Buns]]></dc:creator>
            <pubDate>Sat, 28 Jan 2017 10:12:59 GMT</pubDate>
            <atom:updated>2017-01-28T10:12:58.821Z</atom:updated>
            <content:encoded><![CDATA[<p>It’s a functional programming concept which is being used in javascript land.</p><blockquote><em>Make a chain of functions with one function being argument for the function on left of it. first function — the right most one gets the arguments and it’s return value then provides the signature of argument for rest of the functions in the chain.</em></blockquote><p>Meaning if you have 4 functions func1, func2, func3, func4 and you call them like this</p><pre>let result = func1( func2( func3( func4(value) )))</pre><p>it can be said that you composed. Now instead of doing this by hand what we can do is use a little function like</p><pre>const compose = (...funcs) =&gt; funcs.reduce((a, c) =&gt; (...args) =&gt; a(c(...args)))</pre><p>and then use it like</p><pre>// myComposedFunc will be a callable function which will take One argument</pre><pre>const myComposedFunc = compose((func1, func2, func3, func4)</pre><pre>let result = myComposedFunc(param)</pre><p>Working example</p><pre>//An implementation in javascript for compose functionality<br>const compose = (...funcs) =&gt; funcs.reduce((a, c) =&gt; (...args) =&gt; a(c(...args)))</pre><pre>// An array of json values of an shopping cart<br>const cart = [<br>  { name: &#39;Great God&#39;, cost: 31 , type: &#39;book&#39; },<br>  { name: &#39;Mars&#39;, cost: 17 , type: &#39;DVD&#39; },<br>  { name: &#39;Great God 2&#39;, cost: 22 , type: &#39;book&#39; },<br>  <br>];</pre><pre>// function to Sum call the cost&#39;s in the data<br>const sumAll = (arr) =&gt; arr<br>  .map((item) =&gt; item.cost)<br>  .reduce((acc, cost) =&gt; acc + cost, 0);</pre><pre>console.log(sumAll(cart)); //70</pre><pre>//Get Items of a particular type<br>const getItemsOf = (arr,type) =&gt;<br>	arr.filter((item) =&gt; item.type === type);</pre><pre>console.log(getItemsOf(cart,&#39;book&#39;)); // array of type=book</pre><pre>// Normal way you can call the two functions<br>console.log( sumAll(getItemsOf(cart,&#39;book&#39;)))// 53</pre><pre>// Use compose to get a new function with the right most function getting the arguments<br>let getCostOfBooks = compose(sumAll,getItemsOf)</pre><pre>//Call composed function with the arguments<br>let costOfBooks = getCostOfBooks(cart,&#39;book&#39;);<br>console.log(costOfBooks); //53</pre><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=de44de41a0a" width="1" height="1" alt=""><hr><p><a href="https://medium.com/react-paths/so-what-is-compose-again-de44de41a0a">So What is Compose again?</a> was originally published in <a href="https://medium.com/react-paths">React Paths</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[So what’s Currying again?]]></title>
            <link>https://medium.com/react-paths/so-whats-currying-again-ac17e6586e12?source=rss----55750d1fca6a---4</link>
            <guid isPermaLink="false">https://medium.com/p/ac17e6586e12</guid>
            <category><![CDATA[es6]]></category>
            <category><![CDATA[javascript]]></category>
            <dc:creator><![CDATA[Buns]]></dc:creator>
            <pubDate>Tue, 24 Jan 2017 11:08:26 GMT</pubDate>
            <atom:updated>2017-01-27T07:34:56.097Z</atom:updated>
            <content:encoded><![CDATA[<h3>&gt; Take a function with multiple arguments and create as many functions as arguments</h3><pre>var person = function(name,profession) {<br>    console.log(name + &quot; works as &quot; + profession);<br>};<br>person(&quot;Joe&quot;, &quot;Programmer&quot;); <br>// Joe works as Programmer<br>var person = function(name) {<br>    return function(profession) {<br>        console.log(name + &quot; works as &quot; + profession);<br>    }    <br>};<br>namedPerson = person(&quot;Joe&quot;);<br>namedPerson(&quot;Programmer&quot;);<br>// Joe works as Programmer<br>namedPerson(&quot;Manager&quot;);<br>// Joe works as Manager</pre><p>At one level it’s almost same as creating a class and using that by setting a property name. But here it’s pure function returning functions concept from functional languages.</p><p>As it’s not native to Javascript, ployfill function is the way to go.</p><pre>var curryFn = function(fn) {<br>  var params = Array.prototype.slice.call(arguments, 1);<br>  return function() {<br>    return fn.apply(this, params.concat(<br>      Array.prototype.slice.call(arguments, 0)<br>    ));<br>  };<br>};</pre><p>And to use it, we can take our normal function and curry it</p><pre>var person = function(name,profession) {<br>    console.log(name + &quot; works as &quot; + profession);<br>};</pre><pre>namedPerson = curryFn(person, &quot;Joe&quot;);<br>namedPerson(&quot;Programmer&quot;);<br>// Joe works as Programmer</pre><h3>Redux uses this pattern in it’s connect call</h3><blockquote><em>functionName (param1) (param2)</em></blockquote><p>and I was asked what that was. As this pattern is not native to javascript many tend to think its something new in ES6.</p><p>But actually it’s a way of doing things in functional languages that is being now used in javascript also known as “Currying”</p><p>I am working on another post detailing all the new ES6 goodies which anyone coming from jQuery will need. Will post the link here also.</p><p>Originally Posted on November 1, 2015</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ac17e6586e12" width="1" height="1" alt=""><hr><p><a href="https://medium.com/react-paths/so-whats-currying-again-ac17e6586e12">So what’s Currying again?</a> was originally published in <a href="https://medium.com/react-paths">React Paths</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Convert React createClass to ES6 format in 4 steps]]></title>
            <link>https://medium.com/react-paths/convert-react-createclass-to-es6-format-in-4-steps-fbffa5863315?source=rss----55750d1fca6a---4</link>
            <guid isPermaLink="false">https://medium.com/p/fbffa5863315</guid>
            <category><![CDATA[react]]></category>
            <category><![CDATA[javascript]]></category>
            <dc:creator><![CDATA[Buns]]></dc:creator>
            <pubDate>Tue, 24 Jan 2017 09:48:17 GMT</pubDate>
            <atom:updated>2017-01-24T09:48:16.845Z</atom:updated>
            <content:encoded><![CDATA[<p>React is rally a fast moving target. After 0.13 &amp; 0.14 release, there are big changes are in how we make the Component, how properties, state and the context needs to be handled in constructor. But the better thing is that now the syntax is idiomatic JavaScript and not some special implementation of class.</p><h3>STEP 1 — Constructor &amp; Scope</h3><p>The most important and breaking thing to understand is that you have to now bind the ‘this’ context to the function calls.</p><p>React’s “createClass” automatically bound your methods to a component instance. e.g. it meant that within a Click callback ‘this’ would be bound to the component. Now you must handle this binding ourselves. There are number of ways to achieve that from .bind() to using the Fat Arrow =&gt; syntax. Let’s see an example of both methods.</p><p>OLD</p><pre>var myComponent = React.createClass({<br>  render: function() {<br>    return(<br>      &lt;button onclick=&quot;this.handleClick()&quot;&gt;It&#39;s Me.&lt;/button&gt;<br>    );<br>  },<br>  handleClick: function() {<br>    console.log(this);<br>  }<br>});</pre><p>NEW <strong>Bind “this” context in constructor</strong></p><pre>class myComponent extends React.Component {<br>    constructor() {<br>        super();<br>        this.handleClick = this.handleClick.bind(this); //👈 👈🏽 Bind in the constructor<br>        }<br>    render() {<br>        return(<br>            &lt;button onclick=&quot;this.handleClick()&quot;&gt;It&#39;s Me.&lt;/button&gt;<br>        );  <br>        }<br>    handleClick() {<br>        console.log(this); // this is myComponent<br>    }<br>}</pre><p><strong>Bind “this” context when you call the method</strong></p><pre>class myComponent extends React.Component {<br>    constructor() {<br>        super();<br>        }<br>    render() {<br>        return(<br>            &lt;button onclick=&quot;this.handleClick().bind(this)&quot;&gt;It&#39;s Me.&lt;/button&gt;<br>        );  <br>        }<br>    handleClick() {<br>        console.log(this); // this is myComponent<br>    }<br>}</pre><p><strong>Use the Fat Arrow Syntax</strong></p><pre>class myComponent extends React.Component {<br>    constructor() {<br>        super();<br>    }<br>    render() {<br>        return(<br>            &lt;button onclick=&quot;this.handleClick()&quot;&gt;It&#39;s Me.&lt;/button&gt;<br>        );<br>    }<br>    handleClick = () =&gt; {<br>        console.log(this); // this is myComponent<br>    }<br>}</pre><h3>STEP 2 — Props</h3><p>Class definitions in ES6 only allow one to define methods but not properties. So for that any properties have to be defined outside the class definition.</p><p>Also, now in React the “props” are now immutable so “defaultProps” should be just properties along with the “propTypes”.</p><p>OLD</p><pre>var myComponent = React.createClass({<br>    propTypes: {<br>        myName: React.PropTypes.string<br>    },<br>    getDefaultProps: function() {<br>        return { myName: &#39;Buns&#39; };<br>    }<br>});</pre><p>NEW</p><pre>class myComponent extends React.Component {<br>    constructor() {<br>        super();<br>    }<br>    render() {<br>        return(<br>            &lt;div&gt;My Name is?&lt;/div&gt;<br>        );<br>    }<br>});<br>myComponent.propTypes = {<br>    myName: React.PropTypes.string<br>};<br>myComponent.defaultProps = {<br>    myName: &#39;Buns&#39;<br>};</pre><h3>STEP 3 — State</h3><p>Change how default “State” is defined. Get rid of “getInitialState” method and simply assign it’s return value to “this.state” in the class constructor.</p><p>OLD:</p><pre>var myComponent = React.createClass({<br>    render: function() {<br>        return(<br>            &lt;div&gt;My State is&lt;/div&gt;<br>        );<br>        },<br>    getInitialState: function() {<br>        return Store.getState();<br>    }<br>});</pre><p>NEW:</p><pre>class myComponent extentds React.Component {<br>    constructor() {<br>        super();<br>        this.state = Store.getState();<br>    }<br>    render() {<br>        return(<br>            &lt;div&gt;My State is&lt;/div&gt;<br>        );<br>    }<br>};</pre><h3>STEP 4</h3><p>Include react-dom package and then change React.render to ReactDOM.render</p><p>also change this.getDOMNode to ReactDOM.findDOMNode() to get the dom element associated to the component.</p><p>Originally Posted on October 1, 2015</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=fbffa5863315" width="1" height="1" alt=""><hr><p><a href="https://medium.com/react-paths/convert-react-createclass-to-es6-format-in-4-steps-fbffa5863315">Convert React createClass to ES6 format in 4 steps</a> was originally published in <a href="https://medium.com/react-paths">React Paths</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[React lifecycle in ES6 syntax]]></title>
            <link>https://medium.com/react-paths/react-lifecycle-in-es6-syntax-600f34fbc379?source=rss----55750d1fca6a---4</link>
            <guid isPermaLink="false">https://medium.com/p/600f34fbc379</guid>
            <category><![CDATA[react]]></category>
            <category><![CDATA[javascript]]></category>
            <dc:creator><![CDATA[Buns]]></dc:creator>
            <pubDate>Tue, 24 Jan 2017 09:47:32 GMT</pubDate>
            <atom:updated>2017-01-24T09:47:32.523Z</atom:updated>
            <content:encoded><![CDATA[<p>I had written an post which logged the lifecycle of a react component. Since React 0.14 using ES6 syntax is the way React team wants us to go. You will be seeing most of the new code in ES6 format.</p><p>See “Convert React component to ES6” post to get a todo steps to convert. Following the same I have rehashed the earlier post. There are a couple of differences as explained in convert post and you can now</p><h3>Understand React by seeing it’s Lifecycle</h3><p>React Component has a particular lifecycle in which number of methods gets executed depending on the state of application.</p><h4>Single html file to check and play with</h4><p>Most of the tutorials today start with you having to install node, babel, gulp/webpack etc. The official react site has this little nugget that allows you to just be in your browser having one single file.</p><p>The best way to understand and get your feet wet would be to copy the html file below and run it in your browser.</p><blockquote><em>Open the console and look at the console.logs. I have tried to Group each cycle together.</em></blockquote><p>This example has two very simple components, one <em>“Inner”</em> which is used by main component <em>“App”</em> which is rendered by React under the DIV with id=”root”. This is the mounting part. There is an unmount button which will remove the component from page and you can refresh page to see it work.</p><p>I have given border colors to each of the two components so that you can visually see which component is parent and which is a child. I have found this technique very useful in explaining to others and even myself the hierarchy of the components in a visual way.</p><pre>&lt;!DOCTYPE html&gt;<br>&lt;html&gt;<br>&lt;head&gt;<br>&lt;meta name=&quot;description&quot; content=&quot;React component Lifecycle&quot;&gt;<br>&lt;link data-require=&quot;bootstrap@3.3.2&quot; data-semver=&quot;3.3.2&quot; rel=&quot;stylesheet&quot; href=&quot;//maxcdn.bootstrapcdn.com/bootstrap/3.3.2/css/bootstrap.min.css&quot; /&gt;<br>&lt;script src=&quot;//fb.me/react-0.14.2.js&quot;&gt;&lt;/script&gt;<br>&lt;script  src=&quot;//fb.me/react-dom-0.14.2.js&quot;&gt;&lt;/script&gt;<br>&lt;script src=&quot;https://cdnjs.cloudflare.com/ajax/libs/babel-core/5.8.23/browser.min.js&quot;&gt;&lt;/script&gt;<br>  &lt;meta charset=&quot;utf-8&quot;&gt;<br>  &lt;title&gt;React Component Life Cycle&lt;/title&gt;<br>&lt;/head&gt;<br>&lt;body&gt;<br>  &lt;div id=&#39;root&#39;&gt;&lt;/div&gt;<br> &lt;script type=&quot;text/babel&quot;&gt;<br>    console.log(&#39;Initial&#39;);</pre><pre>    class Inner extends React.Component{</pre><pre>      constructor(){<br>        super();<br>        console.log(&#39;Set init State &amp; Constructor&#39;);<br>        this.state = {foo : 1};<br>      }</pre><pre>      update (){<br>        console.log(&#39;Updating State&#39;);</pre><pre>        this.setState({foo: this.state.foo+1});<br>      }<br></pre><pre>      render() {<br>        console.log(&#39;Render&#39;);<br>        return (<br>          &lt;div style={{border: &quot;2px solid green&quot;}}&gt;<br>          This is in inner that gets Prop from app  &lt;br/&gt;<br>          &lt;button className=&quot;btn&quot;<br>            onClick={this.update.bind(this)}&gt;<br>            Update Value of Foo Via State<br>          &lt;/button&gt;<br>          &lt;h3&gt;this.state.foo: {this.state.foo} &lt;/h3&gt;<br>          &lt;h3&gt;this.props.bar: {this.props.bar}&lt;/h3&gt;<br>          &lt;br/&gt;<br>          &lt;hr/&gt;<br>        &lt;/div&gt;)<br>      }</pre><pre>      componentWillMount() {<br>        console.log(&#39;ComponentWillMount&#39;);<br>      }</pre><pre>      componentDidMount() {<br>        console.log(&#39;ComponentDidMount&#39;);<br>        console.groupEnd(&#39;group&#39;);<br>      }</pre><pre>      shouldComponentUpdate(nextProps, nextState) {<br>        console.group(&#39;group&#39;);<br>        console.log(&#39;ShouldComponentUpdate&#39;,nextProps,nextState);</pre><pre>        return true;<br>      }<br></pre><pre>      componentWillReceiveProps(nextProps) {<br>        console.log(&#39;ComponentWillRecieveProps&#39;);<br>      }</pre><pre>      componentWillUpdate() {<br>        console.log(&#39;ComponentWillUpdate&#39;);<br>      }</pre><pre>      componentDidUpdate() {<br>        console.log(&#39;ComponentDidUpdate&#39;);<br>        console.groupEnd(&#39;group&#39;);<br>      }</pre><pre>      componentWillUnmount() {<br>        console.log(&#39;componentWillUnmount&#39;);<br>      }<br>    };</pre><pre>    Inner.defaultProps = {<br>        bar: 2<br>      };<br>    Inner.propType = {<br>      bar: React.PropTypes.number<br>    }<br></pre><pre>    class App extends React.Component {<br>        constructor() {<br>            super();<br>            this.state = {id:1};<br>            this.update = this.update.bind(this);<br>        }</pre><pre>       update(){<br>         console.log(&#39;Updating Props&#39;);<br>         this.setState({id: this.state.id+10});<br>       }</pre><pre>      shouldComponentUpdate(nextProps, nextState) {<br>        console.log(&#39;ShouldComponentUpdate&#39;,nextProps,nextState);<br>        return true;<br>      }</pre><pre>       unMount(){<br>         ReactDOM.unmountComponentAtNode(document.getElementById(&#39;root&#39;));<br>       }</pre><pre>       render() {<br>        return (<br>          &lt;div style={{border: &quot;2px solid blue&quot;, padding:&quot;20px&quot;}}&gt;<br>          This is in main App&lt;br/&gt;<br>          &lt;button type=&quot;button&quot; className=&quot;btn btn-primary&quot;<br>            onClick={this.update}&gt;<br>            Change Value of Bar Via Props<br>          &lt;/button&gt;&lt;br/&gt;<br>          &lt;hr/&gt;<br>          &lt;Inner bar={this.state.id} /&gt;<br>          &lt;hr /&gt;<br>          &lt;button type=&quot;button&quot; className=&quot;btn&quot;<br>            onClick={this.unMount}&gt;<br>            Unmount App<br>          &lt;/button&gt;<br>          &lt;/div&gt;<br>        )<br>       }<br>    }<br></pre><pre>  ReactDOM.render(&lt;App /&gt;, document.getElementById(&#39;root&#39;));<br> &lt;/script&gt;<br>&lt;/body&gt;<br>&lt;/html&gt;</pre><p>Play around, change the <strong>Prop</strong> and <strong>State</strong> values. When you click the two buttons the values of <strong>foo</strong> &amp; <strong>bar </strong>will change first time, but not after that.</p><p>In console you will notice that lifecycle logs that Render function does fire each time, but internally it checks against VirtualDOM and as nothing changes actual DOM doesn’t get updated.</p><p>Originally Posted on October 4, 2015</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=600f34fbc379" width="1" height="1" alt=""><hr><p><a href="https://medium.com/react-paths/react-lifecycle-in-es6-syntax-600f34fbc379">React lifecycle in ES6 syntax</a> was originally published in <a href="https://medium.com/react-paths">React Paths</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Understand React by seeing it’s Lifecycle]]></title>
            <link>https://medium.com/react-paths/understand-react-by-seeing-its-lifecycle-734c49e4d605?source=rss----55750d1fca6a---4</link>
            <guid isPermaLink="false">https://medium.com/p/734c49e4d605</guid>
            <category><![CDATA[react]]></category>
            <category><![CDATA[javascript]]></category>
            <dc:creator><![CDATA[Buns]]></dc:creator>
            <pubDate>Tue, 24 Jan 2017 09:45:29 GMT</pubDate>
            <atom:updated>2017-01-24T09:45:28.416Z</atom:updated>
            <content:encoded><![CDATA[<p>React Component has a particular lifecycle in which number of methods gets executed depending on the state of application.</p><h4>Single html file to check and play with</h4><p>Most of the tutorials today start with you having to install node, babel, gulp/webpack etc. The official react site has this little nugget that allows you to just be in your browser having one single file.</p><p>The best way to understand and get your feet wet would be to copy the html file below and run it in your browser.</p><blockquote><em>Open the console and look at the console.logs. I have tried to Group each cycle together.</em></blockquote><p>This example has two very simple components, one <em>“Inner”</em> which is used by main component <em>“App”</em> which is rendered by React under the DIV with id=”root”. This is the mounting part. There is an unmount button which will remove the component from page and you can refresh page to see it work</p><pre>&lt;!DOCTYPE html&gt;<br>&lt;html&gt;<br>&lt;head&gt;<br>&lt;meta name=&quot;description&quot; content=&quot;React component Lifecycle&quot;&gt;<br>&lt;link data-require=&quot;bootstrap@3.3.2&quot; data-semver=&quot;3.3.2&quot; rel=&quot;stylesheet&quot; href=&quot;//maxcdn.bootstrapcdn.com/bootstrap/3.3.2/css/bootstrap.min.css&quot; /&gt;<br>&lt;script src=&quot;//fb.me/react-0.13.0.js&quot;&gt;&lt;/script&gt;<br>&lt;script src=&quot;https://cdnjs.cloudflare.com/ajax/libs/babel-core/5.8.23/browser.min.js&quot;&gt;&lt;/script&gt;<br>  &lt;meta charset=&quot;utf-8&quot;&gt;<br>  &lt;title&gt;React Component Lifecycle&lt;/title&gt;<br>&lt;/head&gt;<br>&lt;body&gt;<br>  &lt;div id=&#39;root&#39;&gt;&lt;/div&gt;<br> &lt;script type=&quot;text/babel&quot;&gt;</pre><pre>    var Inner = React.createClass({</pre><pre>      getDefaultProps: function() {<br>        console.group(&#39;Group&#39;);<br>        console.log(&#39;GetDefaultProps&#39;);<br>          return {bar: 2};<br>      },</pre><pre>      getInitialState: function() {<br>        console.log(&#39;GetInitialState&#39;);<br>        return {foo : 1};<br>      },</pre><pre>      update: function() {<br>        console.log(&#39;Updating State&#39;);<br>        this.setState({foo: 2});<br>      },</pre><pre>      render: function() {<br>        console.log(&#39;Render&#39;);<br>        return (&lt;div&gt;<br>          This is in inner that gets Prop from app  &lt;br/&gt;<br>          &lt;button className=&quot;btn&quot;<br>            onClick={this.update}&gt;<br>            Update Value of Foo Via State<br>          &lt;/button&gt;</pre><pre>          &lt;h3&gt;this.state.foo: {this.state.foo} &lt;/h3&gt;<br>          &lt;h3&gt;this.props.bar: {this.props.bar}&lt;/h3&gt;<br>          &lt;br/&gt;<br>          &lt;hr/&gt;<br>        &lt;/div&gt;);<br>      },</pre><pre>      componentWillMount: function() {<br>        console.log(&#39;ComponentWillMount&#39;);<br>      },</pre><pre>      componentDidMount: function() {<br>        console.log(&#39;ComponentDidMount&#39;);<br>        console.groupEnd(&#39;group&#39;);<br>      },</pre><pre>      shouldComponentUpdate: function(nextProps, nextState) {<br>          console.group(&#39;group&#39;);<br>          console.log(&#39;ShouldComponentUpdate&#39;,nextProps,nextState);<br>          return true;<br>      },</pre><pre>      componentWillReceiveProps: function(nextProps) {<br>        console.log(&#39;ComponentWillRecieveProps&#39;,nextProps);<br>      },</pre><pre>      componentWillUpdate: function() {<br>        console.log(&#39;ComponentWillUpdate&#39;);<br>      },</pre><pre>      componentDidUpdate: function() {<br>        console.log(&#39;ComponentDidUpdate&#39;);<br>        console.groupEnd(&#39;group&#39;);<br>      },</pre><pre>      componentWillUnmount: function() {<br>        console.log(&#39;componentWillUnmount&#39;);<br>      }<br>    });</pre><pre>    var App = React.createClass({<br>      getInitialState: function() {<br>        console.log(&#39;GetInitialState&#39;);<br>        return {id : 1};<br>      },</pre><pre>       update: function(){<br>         console.log(&#39;Updating Props&#39;);<br>         this.setState({id: 11});<br>       },</pre><pre>       unMount: function(){<br>         React.unmountComponentAtNode(document.getElementById(&#39;root&#39;));<br>       },</pre><pre>       render: function() {<br>        return (<br>          &lt;div&gt;<br>          This is in main App&lt;br/&gt;<br>          &lt;button type=&quot;button&quot; className=&quot;btn btn-primary&quot;<br>            onClick={this.update}&gt;<br>            Change Value of Bar Via Props<br>          &lt;/button&gt;&lt;br/&gt;<br>          &lt;button type=&quot;button&quot; className=&quot;btn&quot;<br>            onClick={this.unMount}&gt;<br>            Unmount App<br>          &lt;/button&gt;<br>          &lt;hr/&gt;<br>          &lt;Inner bar={this.state.id} /&gt;<br>          &lt;hr /&gt;</pre><pre>          &lt;/div&gt;<br>        )<br>       }<br>    });</pre><pre>    React.render(&lt;App /&gt;, document.getElementById(&#39;root&#39;));<br> &lt;/script&gt;<br>&lt;/body&gt;<br>&lt;/html&gt;</pre><p>Play around, change the <strong>Prop</strong> and <strong>State</strong> values. When you click the two buttons the values of <strong>foo</strong> &amp; <strong>bar </strong>will change first time, but not after that.</p><p>In console you will notice that lifecycle logs that Render function does fire each time, but internally it checks against VirtualDOM and as nothing changes actual DOM doesn’t get updated.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=734c49e4d605" width="1" height="1" alt=""><hr><p><a href="https://medium.com/react-paths/understand-react-by-seeing-its-lifecycle-734c49e4d605">Understand React by seeing it’s Lifecycle</a> was originally published in <a href="https://medium.com/react-paths">React Paths</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to understand React coming from jQuery land]]></title>
            <link>https://medium.com/react-paths/how-to-understand-react-coming-from-jquery-land-c2b0eadb16dd?source=rss----55750d1fca6a---4</link>
            <guid isPermaLink="false">https://medium.com/p/c2b0eadb16dd</guid>
            <category><![CDATA[react]]></category>
            <category><![CDATA[javascript]]></category>
            <dc:creator><![CDATA[Buns]]></dc:creator>
            <pubDate>Tue, 24 Jan 2017 09:44:09 GMT</pubDate>
            <atom:updated>2017-01-24T09:44:08.711Z</atom:updated>
            <content:encoded><![CDATA[<h3>What is React?</h3><p>React is a library used for UI part of the application. Targeted towards SPA’s (Single Page Applications). It is in use in production at many top product from Facebook’s Instagram to Netflix to now even new wp-admin part of wordpress.com.</p><p>The main concept of react as it has crystallized over last one year is that what actually renders the UI can be separate from the logic flow of how to manage the UI. This thought resulted in making the rendering of UI in browser into a separate module now called React-Dom. There are others like React-Canvas which is used by flipboard which allows the UI to be rendered in canvas and finally react-native which generates UI with native components on iOS &amp; Android.</p><h3>Virtual DOM</h3><p>When React first came to scene the fact that it used Virtual Dom was a very big thing. What it meant was that it kept a representation of the DOM in javascript Object and when DOM needed to be changed, you changed the Virtual DOM object first which in turn finds the best and fastest method to update the actual DOM i.e your browser.</p><p>This in turn allowed UI’s to be created based on the State of data. Meaning you define the State as data and based on that data the UI is rendered.</p><h3>Conceptual Difference with jQuery</h3><p>Which is opposite of what you do with jQuery. You change the dom element first and then in rare cases you stored the changed value / state either in a Javascript object or even on the DOM element with data- attribute. In an complex UI there are multiple permutations and multiple events changing the UI state and handling those becomes more &amp; more difficult over time.</p><p>But in React, UI is built based on State data, you can change that anywhere and final UI will still be same. You could actually save a State on say server and when you build the UI again based on that state you can be sure that you will get what was the original UI. This fact and ability of React to render in a string due to VirtualDOM allows UI’s to be generated on server side also, now known as Universal Apps.</p><h3>But… but that’s going to be so slow!!</h3><p>That’s the first thought. You mean that when I click a checkbox, the whole page is going to be re rendered? Well, yes and no. The virtual DOM has diffing algorithms and is smart enough to know what has changed and only update that part of DOM. Though you don’t have to think, you just set the state that represents that checkbox as selected/notSelected.</p><p>Originally Posted on November 3, 2015</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c2b0eadb16dd" width="1" height="1" alt=""><hr><p><a href="https://medium.com/react-paths/how-to-understand-react-coming-from-jquery-land-c2b0eadb16dd">How to understand React coming from jQuery land</a> was originally published in <a href="https://medium.com/react-paths">React Paths</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>