<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Saroj Subedi on Medium]]></title>
        <description><![CDATA[Stories by Saroj Subedi on Medium]]></description>
        <link>https://medium.com/@kaissaroj?source=rss-d9e60d34e028------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*6Yp10QJVrLswzE3haDk-bg.jpeg</url>
            <title>Stories by Saroj Subedi on Medium</title>
            <link>https://medium.com/@kaissaroj?source=rss-d9e60d34e028------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 28 Nov 2026 02:37:34 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@kaissaroj/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Sitemaps & Robots.txt in NextJS]]></title>
            <link>https://kaissaroj.medium.com/sitemaps-robots-txt-in-nextjs-ebd63d0c648?source=rss-d9e60d34e028------2</link>
            <guid isPermaLink="false">https://medium.com/p/ebd63d0c648</guid>
            <category><![CDATA[nextjs]]></category>
            <category><![CDATA[reactjs]]></category>
            <dc:creator><![CDATA[Saroj Subedi]]></dc:creator>
            <pubDate>Sat, 25 Sep 2021 04:46:19 GMT</pubDate>
            <atom:updated>2021-09-25T04:46:19.218Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*EF7xbGvpBGOTRWOE" /><figcaption>Photo by <a href="https://unsplash.com/@rocknrollmonkey?utm_source=medium&amp;utm_medium=referral">Rock&#39;n Roll Monkey</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>If we want to communicate and provide certain information to search engines &amp; crawlers about your website, then it is good to have sitemaps and robots.txt file. With those on place in site, we can :</p><ul><li>Define paths and location of sites which are public and private</li><li>Pin pages as achieve so crawler will know</li><li>Define priority level, page updated frequency rate</li><li>Provide search engines info which pages are important in order to index them faster than others</li></ul><p>Here is basic example of sitemap:</p><pre>&lt;urlset xmlns=&quot;http://www.sitemaps.org/schemas/sitemap/0.9&quot;&gt;<br>   &lt;url&gt;<br>      &lt;loc&gt;http://www.example.com/&lt;/loc&gt;<br>      &lt;lastmod&gt;2020-01-01&lt;/lastmod&gt;<br>      &lt;changefreq&gt;monthly&lt;/changefreq&gt;<br>      &lt;priority&gt;0.8&lt;/priority&gt;<br>   &lt;/url&gt;<br>&lt;/urlset&gt;</pre><p>For detailed specification, check <a href="https://www.sitemaps.org/protocol.html">here</a>.</p><h3><strong>Create a Sitemap:</strong></h3><p><em>For this example I am assuming our site is a normal blog with lots of posts.</em></p><p>Create a file called <strong><em>pages/api/sitemap.js</em></strong></p><pre><em>import { getBlogPosts } from &#39;../utils/data&#39;<br></em></pre><pre><em>export default async function sitemap(req, res) {</em></pre><pre><em>    const postLists = await getBlogPosts()<br>    <br>    const entries = postLists.map(post =&gt; getSitemapEntry({<br>        pathname: `/post/${post.slug}`<br>    }))</em></pre><pre><em>    entries.push(getSitemapEntry({<br>        pathname: &#39;/&#39;,<br>        priority: 1<br>    }))</em></pre><pre><em>    const sitemap = `<br>        &lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;<br>        &lt;urlset xmlns=&quot;http://www.sitemaps.org/schemas/sitemap/0.9&quot;&gt;<br>            ${entries.join(&#39;\n&#39;)}<br>        &lt;/urlset&gt;      <br>    `.trim()<br><br>    res.writeHead(200, {<br>        &#39;Content-Type&#39;: &#39;application/xml&#39;<br>    })</em></pre><pre><em>    return res.end(sitemap);<br>}</em></pre><pre><em>const hostname = &quot;https://mytestblog.com&quot;</em></pre><pre><em>function getSitemapEntry({pathname, priority = 0.5}) {<br>    return `<br>        &lt;url&gt;<br>            &lt;loc&gt;${hostname}${pathname}&lt;/loc&gt;<br>        &lt;/url&gt;<br>    `<br>}</em></pre><p>Now we need to map <strong>/api/sitemap</strong> to <strong>/sitemap.xml. </strong>For this go to <strong>next.config.js </strong>file</p><pre>module.exports = {<br>    async rewrites() {<br>        return [<br>            {<br>                source: &#39;/sitemap.xml&#39;,<br>                destination: &#39;/api/sitemap&#39;,<br>            },<br>        ]<br>    },<br>}</pre><p>We can now access sitemap in <a href="http://localhost:3009/sitemap.xml">http://localhost:3000/sitemap.xml</a></p><p>Lets create a <strong>robots.txt </strong>file. Go to public folder and create robots.txt file and paste this:</p><pre>User-agent: *<br>Disallow: /api<br>Sitemap: https:<em>//mytestblog.com/sitemap.xml</em></pre><p>Check <a href="https://en.wikipedia.org/wiki/Robots_exclusion_standard">here</a> if you want to have more information about robots.txt</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ebd63d0c648" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[SvelteJS component’s lifecycle  for React developers]]></title>
            <link>https://kaissaroj.medium.com/sveltejs-components-lifecycle-for-react-developers-39cd970ba2ce?source=rss-d9e60d34e028------2</link>
            <guid isPermaLink="false">https://medium.com/p/39cd970ba2ce</guid>
            <category><![CDATA[svelte]]></category>
            <category><![CDATA[react]]></category>
            <category><![CDATA[javascript]]></category>
            <dc:creator><![CDATA[Saroj Subedi]]></dc:creator>
            <pubDate>Mon, 07 Dec 2020 13:36:19 GMT</pubDate>
            <atom:updated>2020-12-07T13:44:38.038Z</atom:updated>
            <content:encoded><![CDATA[<h3>SvelteJS component’s lifecycle for React developers</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*zTfSttOEoNS577lqj6zliw.png" /><figcaption>SvelteJS for React Developers</figcaption></figure><p>I am working as React Developer for past 3 years now. I love to work with ReactJS/React Native. For some months I am using SvelteJS for my small and personal projects and it’s new fresh air in the JS environment and am really enjoying it.</p><p>I have already written some articles related to SvelteJS.</p><ul><li><a href="https://levelup.gitconnected.com/basic-introduction-to-sveltejs-todoapp-9d174ebb99f9">A Basic Introduction to Svelte by Building a TodoApp App</a></li><li><a href="https://medium.com/@kaissaroj/sveltejs-components-lifecycle-b01ac0cf6d59">SvelteJS component’s lifecycle</a></li></ul><p>I find lifecycle in ReactJS and SvelteJS very much similar and very easy to understand. If you want to understand the lifecycle of React(class based lifecycle), check <a href="https://medium.com/@kaissaroj/minimalist-guide-for-react-component-life-cycle-with-examples-2132e0d90dc1">this</a>.</p><p>I will be comparing the useEffect hook of React to lifecycle of Svelte.</p><h3>Mounting (initialization)</h3><p>Mounting is the initial and first lifecycle of any component where component is created and inserted in DOM.</p><p><a href="https://reactjs.org/docs/hooks-reference.html#useeffect"><strong>REACT</strong></a><strong>:</strong></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/e4d0b4fcbb67bb977c3f1c1bd4a7ba0d/href">https://medium.com/media/e4d0b4fcbb67bb977c3f1c1bd4a7ba0d/href</a></iframe><p><a href="https://svelte.dev/docs#onMount"><strong>SVELTE</strong></a><strong> :</strong></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/b7b93790971496a21afd8110ff1173c9/href">https://medium.com/media/b7b93790971496a21afd8110ff1173c9/href</a></iframe><h3>After/Before Update</h3><p>If there is any state change, we can listen that update or get inform about that change.</p><p><a href="https://reactjs.org/docs/hooks-reference.html#useeffect"><strong>REACT</strong></a><strong>:</strong></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/f9366a144d238ae780bf282964001b97/href">https://medium.com/media/f9366a144d238ae780bf282964001b97/href</a></iframe><p><a href="https://svelte.dev/docs#beforeUpdate"><strong>SVELTE</strong></a><strong> :</strong></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/7c5f0d06cc6873454f15fa1c3fe68cd5/href">https://medium.com/media/7c5f0d06cc6873454f15fa1c3fe68cd5/href</a></iframe><h3>UnMount/Destory</h3><p>After component is leaved or unmounted, we need to perform some tasks.</p><p><a href="https://reactjs.org/docs/hooks-reference.html#useeffect"><strong>REACT</strong></a><strong>:</strong></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/9db132af2ebd1b3f75aa218c357fd70c/href">https://medium.com/media/9db132af2ebd1b3f75aa218c357fd70c/href</a></iframe><p><a href="https://svelte.dev/docs#onDestroy"><strong>SVELTE</strong></a><strong> :</strong></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/94374fc552f828c0889e8acbd404e0ae/href">https://medium.com/media/94374fc552f828c0889e8acbd404e0ae/href</a></iframe><p><a href="https://svelte.dev/"><strong>SvelteJS</strong></a> is very easy to learn and follow. Try once, you will love it.</p><p><em>Thanks for reading.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=39cd970ba2ce" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[What’s new in React Native 0.62]]></title>
            <link>https://kaissaroj.medium.com/whats-new-in-react-native-0-62-5a9305d65d?source=rss-d9e60d34e028------2</link>
            <guid isPermaLink="false">https://medium.com/p/5a9305d65d</guid>
            <category><![CDATA[react-native]]></category>
            <category><![CDATA[react]]></category>
            <dc:creator><![CDATA[Saroj Subedi]]></dc:creator>
            <pubDate>Fri, 27 Mar 2020 03:06:58 GMT</pubDate>
            <atom:updated>2020-03-27T03:06:58.915Z</atom:updated>
            <content:encoded><![CDATA[<p>There are some awesome new features and support tools added in new release of React Native. Lets have a look.</p><ul><li><a href="https://fbflipper.com/"><strong>Flipper</strong></a>: Flipper is a mobile app debugger. Its highly used in native android and IOS development. Now Flipper support React Native by default.</li><li><strong>New Dark Features</strong>: New Appearance module has been added which provides user appearance preferences.</li></ul><pre>const colorScheme = Appearance.getColorScheme(); //dark, light</pre><ul><li><a href="https://react-native-community.github.io/upgrade-helper/"><strong>Upgrade tool</strong></a>: The community has create a new upgrade helper tool to support developers upgrading to new versions of React Native. The upgrade helper provides a diff of changes from the version you’re on to the version you’re targeting, allowing you to see the changes that need to be made for your specific upgrade. check this <a href="https://react-native-community.github.io/upgrade-helper/?from=0.61.5&amp;to=0.62.0"><em>example</em></a>.</li><li><strong>LogBox:</strong> New logging features has been added. To enable this, add this line of code in <strong><em>index.js</em></strong> file.</li></ul><p>require(&#39;react-native&#39;).unstable_enableLogBox()</p><p>These are main features in react native new release. There are others features too and some breaking changes. check <a href="https://reactnative.dev/blog/2020/03/26/version-0.62"><em>here</em></a>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5a9305d65d" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[React Native Starter Introduction]]></title>
            <link>https://kaissaroj.medium.com/react-native-starter-introduction-18235013cf7e?source=rss-d9e60d34e028------2</link>
            <guid isPermaLink="false">https://medium.com/p/18235013cf7e</guid>
            <category><![CDATA[react-native]]></category>
            <dc:creator><![CDATA[Saroj Subedi]]></dc:creator>
            <pubDate>Wed, 25 Dec 2019 05:31:30 GMT</pubDate>
            <atom:updated>2019-12-25T05:31:30.983Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*NeeD0uYwkfUwGx04" /><figcaption>Photo by <a href="https://unsplash.com/@jontyson?utm_source=medium&amp;utm_medium=referral">Jon Tyson</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>React Native is like React, but it uses native components instead of web components as building blocks. If you already know React, you still need to learn some React-Native-specific stuff, like the native components.</p><p><strong>Create A New Project</strong></p><p>There is basically two ways(cli) for Bootstrapping a react native app .</p><p><strong>Expo Cli QuickStart</strong></p><ul><li>npm install -g expo-cli</li><li>expo init NewProject</li></ul><p><strong>React Native CLI Quickstart</strong></p><ul><li>brew install node</li><li>brew install watchman</li><li>npm i react-native-cli</li><li>npm react-native init NewProject</li></ul><p>If you want to know difference between these two cli . Check <a href="https://stackoverflow.com/questions/54862388/what-is-the-difference-between-expo-cli-and-react-native-cli">this</a>.</p><p><strong>State Management</strong></p><p>Next thing we need to consider is what kind of state management library do we want to use for React Native. Its same like for React. I personally prefer MobX libary or React Context. There is also Redux- most famous state management library. For more check this <a href="https://github.com/cs01/awesome-react-state-management-tools">link</a>.</p><p><strong>Project File Structure</strong></p><p>In React Native, we can organize the project however we want. It depends on person to person. I organize my file structure based on <strong><em>functionality</em></strong> and <strong><em>code reusability</em></strong>.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/a189f15f329a7492717695dd9b2e0890/href">https://medium.com/media/a189f15f329a7492717695dd9b2e0890/href</a></iframe><ul><li><strong><em>components</em></strong> : To achieve maximum code reuse and minimum state management. We can create functional components inside this directory. And can be call and use all overall the project.</li><li><strong><em>config</em></strong>: All the settings and constants which we need in app can be define inside this folder.</li><li><strong><em>screens</em></strong>: Views/Screens — Main Routing Pages can be define inside this folder.</li><li><strong><em>states</em></strong>: Code related to state management can be include this folder.</li><li><strong><em>services</em></strong>: Codes which connect the state actions and api can be written inside this folder files.</li></ul><p><strong>Navigation Libaries:</strong></p><p>There are a-lot of React Native Navigation Libraries. Personally I prefer <a href="https://reactnavigation.org/">React Navigation</a>.</p><p>Others:</p><ul><li><a href="https://github.com/aksonov/react-native-router-flux">React Native Flux</a></li><li><a href="https://github.com/wix/react-native-navigation">React Native Navigation</a></li></ul><p>— — — — — — — — — — — — — — — — — — — — — — — — — — — — — —</p><p>If you want more awesomeness , then go to this link.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=18235013cf7e" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[SvelteJS component’s lifecycle]]></title>
            <link>https://kaissaroj.medium.com/sveltejs-components-lifecycle-b01ac0cf6d59?source=rss-d9e60d34e028------2</link>
            <guid isPermaLink="false">https://medium.com/p/b01ac0cf6d59</guid>
            <category><![CDATA[lifecycle]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[sveltejs]]></category>
            <category><![CDATA[lifecycle-methods]]></category>
            <dc:creator><![CDATA[Saroj Subedi]]></dc:creator>
            <pubDate>Thu, 26 Sep 2019 19:21:16 GMT</pubDate>
            <atom:updated>2019-09-26T19:21:16.685Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*Qv8TaGhtr47vDf5p" /><figcaption>Photo by <a href="https://unsplash.com/@danm?utm_source=medium&amp;utm_medium=referral">Dan Musat</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>Components complete a full life cycle from creation to destruction. During that period, Svelte provides some handful of functions that allow us to run code at specific moments.</p><p>Lets take a look at those functions.</p><ul><li>onMount</li><li>beforeUpdate</li><li>afterUpdate</li><li>onDestroy</li><li>tick</li></ul><p><strong>onMount:</strong></p><pre>onMount(callback: () =&gt; () =&gt; void)</pre><p>It is triggered after the component is first rendered to dom. It must be called during the component’s initialization. Some tasks which can be performed under this method are :</p><ul><li>timers/intervals functions</li><li>fetching data</li></ul><p>If a function is returned from <em>onMount</em>, that it will be executed after component is destroyed.</p><p>Live demo <a href="https://svelte.dev/repl/2e976c8411ad4bbbace89dee9b51c987?version=3">here</a></p><pre>&lt;script&gt;</pre><pre> import { onMount } from &#39;svelte&#39;;<br> <br> let counter = 0;</pre><pre> onMount(() =&gt; {<br> <br> console.log(&#39;the component has mounted&#39;);</pre><pre>   // get dom element by id<br>  console.log(document.getElementById(&#39;tag&#39;));</pre><pre>  //intervals functions<br>  const interval = setInterval(() =&gt; {<br>   counter = counter + 1;<br>  }, 1000);</pre><pre>  //If a function is returned from onMount, it will be called when   the component is unmounted.<br>  return () =&gt; clearInterval(interval);<br> });<br>&lt;/script&gt;</pre><pre>&lt;h1 id=&quot;tag&quot;&gt;<br> {counter}<br>&lt;/h1&gt;</pre><p><strong>beforeUpdate &amp; afterUpdate:</strong></p><pre>beforeUpdate(callback: () =&gt; void)<br>afterUpdate(callback: () =&gt; void)</pre><p>If there is any state change, then component needs to update and before any update, ‘<em>beforeUpdate’ </em>is triggered. ‘<em>beforeMount’ </em>is called for first time when component is mounted.</p><p>Counterpart of <em>‘beforeUpdate’ </em>is <em>‘afterUpdate’</em> which is called after component update is completed.</p><p>Live demo <a href="https://svelte.dev/repl/9a24a35072c64af5b7bfde6c806c43d3?version=3.12.1">here</a></p><pre>&lt;script&gt;<br> import { onMount, beforeUpdate, afterUpdate } from &#39;svelte&#39;;<br> let counter = 0;</pre><pre>  beforeUpdate(() =&gt; {<br>  console.log(&#39;the component is going to be updated&#39;);<br> });</pre><pre>  afterUpdate(() =&gt; {<br>  console.log(&#39;the component has been updated&#39;); <br>  });</pre><pre> onMount(() =&gt; {<br>  const interval = setInterval(() =&gt; {<br>   counter = counter + 1;<br>  }, 1000);<br>  return () =&gt; clearInterval(interval);<br> });<br>&lt;/script&gt;<br>&lt;h1&gt;{counter}&lt;/h1&gt;</pre><p><strong>onDestroy</strong></p><pre>onDestroy(callback: () =&gt; void)</pre><p>Any task which need to be done after component is destroyed should be done inside <em>‘onDestroy’</em>.</p><pre>&lt;script&gt;<br>	import { onDestroy } from &#39;svelte&#39;;<br><br>	onDestroy(() =&gt; {<br>		console.log(&#39;the component is being destroyed&#39;);<br>	});<br>&lt;/script&gt;</pre><p><strong>tick:</strong></p><pre>promise: Promise = tick()</pre><p>Its different from other life cycle methods. It can be called anytime anywhere after the component is mounted.</p><p>If one update is running and has not been completed, <em>‘tick’</em> method helps to control or pause the other upcoming updates until the current update is completed. It returns a promise that resolves as soon as any pending state changes have been applied to the DOM.</p><p>Live demo <a href="https://svelte.dev/repl/a4274f4ac87142f28305a05419f4aa7e?version=3.12.1">here</a></p><pre>&lt;script&gt;<br> import {beforeUpdate, tick } from &#39;svelte&#39;;</pre><pre> let counter = 1;</pre><pre> setInterval(() =&gt; {<br>  counter++;<br> },2000);</pre><pre> beforeUpdate(async () =&gt; {<br>  console.log(&#39;the component is about to update&#39;);<br>  await tick();<br>  console.log(&#39;the component just updated&#39;);<br> });</pre><pre>&lt;/script&gt;</pre><pre>&lt;p&gt;Number : {counter}&lt;/p&gt;</pre><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b01ac0cf6d59" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[New Features in React Router v5.1.0]]></title>
            <link>https://kaissaroj.medium.com/new-features-in-react-router-v5-1-0-12c726883190?source=rss-d9e60d34e028------2</link>
            <guid isPermaLink="false">https://medium.com/p/12c726883190</guid>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[router]]></category>
            <category><![CDATA[react-router]]></category>
            <category><![CDATA[react]]></category>
            <dc:creator><![CDATA[Saroj Subedi]]></dc:creator>
            <pubDate>Wed, 25 Sep 2019 03:46:13 GMT</pubDate>
            <atom:updated>2019-09-25T03:46:13.895Z</atom:updated>
            <content:encoded><![CDATA[<p>There are some awesome new features added in React Router v5.1.0. Hooks are hot topic now and that’s what we are getting in new React Router version.</p><p>Lists of Hooks added:</p><ul><li><em>useParams</em></li><li><em>useLocation</em></li><li><em>useHistory</em></li><li><em>useRouteMatch</em></li></ul><p><strong>userParams</strong>: To access current params, we use match prop passed to component like this:</p><pre>let { id } = match.params;</pre><p>But we with new hooks, we can just use like this in stateless component</p><pre>let { id } = useParams();</pre><p>**We can <em>useParams()</em> anywhere in &lt;Components&gt; or its subtree without manually passing params around**</p><p><strong>userLocation</strong>: Which returns the current location object</p><pre>let current_location = useLocation();</pre><p><strong>userHistory</strong>: Use for programmatic navigation purposes.</p><pre>let history = useHistory();</pre><p><strong>useRouteMatch</strong>: Useful when we are using&lt;Route&gt;just so we can get access to its match data.</p><pre>let match = useRouteMatch({<br>    path: &#39;/post/:id/&#39;,<br>    strict: true,<br>    sensitive: true<br>  })</pre><p><strong>Other Updates:</strong></p><ul><li>Add support for forwardRef in &lt;Link&gt;</li></ul><pre>This allows components like @reach/menu-button to manage focus or do anything else they need to with the underlying DOM element.</pre><ul><li>Add support for functions in &lt;Link to&gt; and &lt;NavLink to&gt;</li><li>Add &lt;Link component&gt; API</li></ul><pre>&lt;Link<br>     to=&quot;/page&quot;<br>     component={PageView}<br>     &gt;<br>        &lt;Text&gt;Page1&lt;/Text&gt;<br>&lt;/Link&gt;</pre><p>For more check React Router <a href="https://github.com/ReactTraining/react-router/releases/tag/v5.1.0">releases</a>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=12c726883190" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[A Basic Introduction to Svelte by Building a TodoApp App]]></title>
            <link>https://levelup.gitconnected.com/basic-introduction-to-sveltejs-todoapp-9d174ebb99f9?source=rss-d9e60d34e028------2</link>
            <guid isPermaLink="false">https://medium.com/p/9d174ebb99f9</guid>
            <category><![CDATA[todo]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[sveltejs]]></category>
            <dc:creator><![CDATA[Saroj Subedi]]></dc:creator>
            <pubDate>Tue, 24 Sep 2019 09:18:18 GMT</pubDate>
            <atom:updated>2019-09-26T16:56:48.021Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*PsNUrve6BcG588SHcf85xg.jpeg" /></figure><blockquote>SvelteJS is not just another JS library or framework — it is a modern Javascript compiler.</blockquote><h4><strong>What is SvelteJS</strong></h4><p>Svelte.js (or just “Svelte”) is a modern JavaScript compiler that allows you to write easy-to-understand JavaScript code that is then compiled to highly efficient code that runs in the browser.</p><p>It is similar to <a href="https://reactjs.org/docs/getting-started.html">React</a> or <a href="https://vuejs.org/v2/guide/">Vue</a>, but in Svelte, we don’t have any dependencies. That means it will not take any time to interpret our code, so we will get pure JavaScript before runtime. We just write simple, normal Javascript code with some Svelte rules, and Svelte will compile that code to a highly optimised JavaScript code bundle that runs directly in the browser.</p><p>There are many features and advantages of using Svelte over other JS libraries, which I will be discussing in the next article. But for now, we will write a simple todo app which will help us to understand the basics of Svelte.</p><p>First create starter files for this project.</p><pre>npx degit sveltejs/template svelte-app</pre><p>Then run <strong>npm install &amp;&amp; npm run dev</strong>.</p><p>Check the src folder, and you will see the files App.svelte and main.js.</p><p>Svelte components are composed in .svelte files.</p><pre>&lt;script&gt;<br> // component logic<br>&lt;/script&gt;</pre><pre>&lt;style&gt;<br> /* component specific styles */<br>&lt;/style&gt;</pre><pre>&lt;! — component markup --&gt;</pre><p>Now let’s write some basic HTML code.</p><pre>&lt;div class=”container”&gt;<br>  &lt;main&gt;<br>    &lt;div class=”container”&gt;<br>      &lt;p class=”empty-state__description”&gt;Add Todo Lists&lt;/p&gt;<br>      &lt;form&gt;<br>        &lt;input<br>          type=”text”<br>          aria-label=”Enter a new todo item”<br>          placeholder=”eg. gyms”<br>        /&gt;<br>      &lt;/form&gt;<br>    &lt;/div&gt;<br>  &lt;/main&gt;<br>&lt;/div&gt;</pre><p>Add some styles too.</p><pre>.container {</pre><pre>  height: 100%;</pre><pre>  width: 500px;</pre><pre>  margin: 0 auto;</pre><pre>}</pre><pre>h1 {</pre><pre>  color: blue;</pre><pre>}</pre><pre>ul {</pre><pre>  list-style-type: none;</pre><pre>}</pre><pre>.checked {</pre><pre>  text-decoration: line-through;</pre><pre>}</pre><pre>a {</pre><pre>  text-decoration: none;</pre><pre>}</pre><p>Now we will create a basic JavaScript class which will be responsible for initialising variables and functions.</p><pre>class TodoApp {</pre><pre>  constructor() {</pre><pre>    this.todoItems = [];</pre><pre>    this.newTodo = “”;</pre><pre>  }</pre><pre>  addTodo() {</pre><pre>    todoApp.newTodo = todoApp.newTodo.replace(/ /g, “”);</pre><pre>    if (todoApp.newTodo.length == 0) return;</pre><pre>    const todo = {</pre><pre>      id: todoApp.todoItems.length + 1,</pre><pre>      text: todoApp.newTodo,</pre><pre>      checked: false</pre><pre>    };</pre><pre>    todoApp.todoItems = […todoApp.todoItems, todo];</pre><pre>    todoApp.newTodo = “”;</pre><pre>  }</pre><pre>  toggleDone(id) {</pre><pre>    const index = todoApp.todoItems.findIndex(item =&gt; item.id === Number(id));</pre><pre>    todoApp.todoItems[index].checked =   !todoApp.todoItems[index].checked;</pre><pre>  }</pre><pre>  remove(id) {</pre><pre>    todoApp.todoItems = todoApp.todoItems.filter(</pre><pre>      item =&gt; item.id !== Number(id)</pre><pre>    );</pre><pre>  }</pre><pre>}</pre><pre>const todoApp = new TodoApp();</pre><p>Let me explain above code.</p><p>We create TodoApp class, where we initialise two variables todoItems and newTodo.</p><p>There are three functions :</p><p>addTodo:<strong><em> </em></strong>Where we create a newTodo and push it to todoItems.</p><p>toggleDone: Where we toggle if a task is completed or not.</p><p>remove: Where we remove the selected todo item.</p><p>Now we update the JS actions in the HTML code:</p><pre>&lt;div class=”container”&gt;</pre><pre>  &lt;p class=”empty-state__description”&gt;Add Todo Lists&lt;/p&gt;</pre><pre>  &lt;form on:submit|preventDefault={todoApp.addTodo}&gt;</pre><pre>    &lt;input</pre><pre>      type=”text”</pre><pre>      aria-label=”Enter a new todo item”</pre><pre>      placeholder=”eg. gyms”</pre><pre>      bind:value={todoApp.newTodo} /&gt;</pre><pre>  &lt;/form&gt;</pre><pre>  &lt;ul class=”todo-list”&gt;</pre><pre>     {#each todoApp.todoItems as todo (todo.id)}</pre><pre>        &lt;li class=”todo-item”&gt;</pre><pre>          &lt;a</pre><pre>            href=”javascript:void(0)”</pre><pre>            on:click={() =&gt; todoApp.toggleDone(todo.id)}&gt;</pre><pre>            &lt;span class={todo.checked ? ‘checked’ : ‘’}&gt;<br>              {todo.text}<br>            &lt;/span&gt;</pre><pre>          &lt;/a&gt;</pre><pre>          &lt;button</pre><pre>            class=”delete-todo”</pre><pre>            on:click={() =&gt; todoApp.remove(todo.id)}&gt;</pre><pre>            X</pre><pre>          &lt;/button&gt;</pre><pre>        &lt;/li&gt;</pre><pre>      {/each}</pre><pre>   &lt;/ul&gt;</pre><pre>&lt;/div&gt;</pre><p>That&#39;s all! It’s a simple implementation of Svelte to provide a general overview. Check this tutorial for further learnings. <a href="https://svelte.dev/tutorial/basics">https://svelte.dev/tutorial/basics</a>.</p><p>Source Code : <a href="https://github.com/kaissaroj/svelte-todo-app">https://github.com/kaissaroj/svelte-todo-app</a></p><p><a href="https://gitconnected.com/learn">Learn to Code - Find Programming Tutorials | gitconnected</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9d174ebb99f9" width="1" height="1" alt=""><hr><p><a href="https://levelup.gitconnected.com/basic-introduction-to-sveltejs-todoapp-9d174ebb99f9">A Basic Introduction to Svelte by Building a TodoApp App</a> was originally published in <a href="https://levelup.gitconnected.com/">Level Up Coding</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Closures, Anonymous Function & High Order Functions in PHP]]></title>
            <link>https://kaissaroj.medium.com/closures-anonymous-function-high-order-functions-in-php-283beb690006?source=rss-d9e60d34e028------2</link>
            <guid isPermaLink="false">https://medium.com/p/283beb690006</guid>
            <category><![CDATA[anonymous-function]]></category>
            <category><![CDATA[php-development]]></category>
            <category><![CDATA[closures-functions]]></category>
            <category><![CDATA[high-order-functions]]></category>
            <category><![CDATA[php]]></category>
            <dc:creator><![CDATA[Saroj Subedi]]></dc:creator>
            <pubDate>Tue, 17 Sep 2019 05:49:16 GMT</pubDate>
            <atom:updated>2019-09-17T05:49:16.698Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*xzkRm9kP8kMCeUm2" /><figcaption>Photo by <a href="https://unsplash.com/@yiranding?utm_source=medium&amp;utm_medium=referral">Yiran Ding</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p><strong>Closures </strong>are introduced in PHP 5.3. Functions which are created without any name (Anonymous Function) and Closures functions are used to represent these kind of functions.</p><p>A closure is good when we want a local function that’s only used for some small specific purposes.</p><p>Basically, Closure are the inner functions that have access to outer variables and used as a callback function to anonymous functions.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/7bfcce32a8c351cd696616265d639b3b/href">https://medium.com/media/7bfcce32a8c351cd696616265d639b3b/href</a></iframe><p><strong>High Order function </strong>are related to functional programming. Basically these kind of functions has at least one of these features.</p><ul><li>Takes one or more functions as arguments.</li><li>Return a function as its result.</li></ul><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/490d8dfe949946e1e3cb799c04251e24/href">https://medium.com/media/490d8dfe949946e1e3cb799c04251e24/href</a></iframe><p>Here are some inbuilt High Order Functions in PHP which will be more helpful to write clean and fast codes.</p><ul><li>array_map</li><li>array_filter</li><li>array_reduce</li><li>array_walk</li></ul><p><strong>array_map : </strong>Applies the callback to the elements of the given arrays</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/7f9446527ec91c6bda68f9b6389b763d/href">https://medium.com/media/7f9446527ec91c6bda68f9b6389b763d/href</a></iframe><p><strong>array_filter : </strong>Filters elements of an array using a callback function</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/9534ff75851b0b96240486d51fe23ae0/href">https://medium.com/media/9534ff75851b0b96240486d51fe23ae0/href</a></iframe><p><strong>array_reduce: </strong>Iteratively reduce the array to a single value using a callback function</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/20d85ad53cfa36042a7145148b51f1a7/href">https://medium.com/media/20d85ad53cfa36042a7145148b51f1a7/href</a></iframe><p><strong>array_walk : </strong>Apply a user supplied function to every member of an array</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/f207f7d38853b6d60fafb31be65c0f5e/href">https://medium.com/media/f207f7d38853b6d60fafb31be65c0f5e/href</a></iframe><p>PS; One more thing. lets try to use external variable inside high order function here : <strong><em>array_map</em></strong></p><pre>$add = 2;</pre><pre>$lists = [1,2,3,4,5];</pre><pre>array_map(function($value){<br> return $value + $add;<br> }, $lists);</pre><p>We will get this error: <strong><em>Undefined variable: add</em></strong></p><p>To solve this, we need to supply external variable to function using `<strong>use</strong>` keyboard.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/4d85b4f4d8956d4b2996d665c13c406d/href">https://medium.com/media/4d85b4f4d8956d4b2996d665c13c406d/href</a></iframe><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=283beb690006" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Asynchronous Process inside For loop (JS#1)]]></title>
            <link>https://kaissaroj.medium.com/asynchronous-process-inside-for-loop-js-1-972bcf67a146?source=rss-d9e60d34e028------2</link>
            <guid isPermaLink="false">https://medium.com/p/972bcf67a146</guid>
            <category><![CDATA[asynchronous]]></category>
            <category><![CDATA[javascript]]></category>
            <dc:creator><![CDATA[Saroj Subedi]]></dc:creator>
            <pubDate>Tue, 28 May 2019 06:34:04 GMT</pubDate>
            <atom:updated>2019-05-28T06:38:52.225Z</atom:updated>
            <content:encoded><![CDATA[<p>Let say we need to run asynchronous task inside For loop. Check this example below:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/958/1*Kw_SBRPxYwz9utkjdEq7Gw.png" /></figure><p>Guess the value of iprint by console. If you guess 0 &amp; 1, then you are wrong. <br>Let me explain why.</p><p>The forloop runs immediately to complete. It will not wait the asynchronous operations to start or end.<br>When they complete some time in the future and call their callbacks, the value of your loop index variable iwill be at its last value for all the callbacks.</p><p>So the output will be 2 &amp; 2.</p><p>There are two solutions for this problem.</p><ul><li>Create a closure function and save loop index separately for each callback.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/958/1*g5ZMkokHn6djlQ8Zojng9A.png" /></figure><ul><li>ES6 solution , use letto define variable of forloop. As letis blocked scope and uniquely defined for each iteration.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/958/1*c3qwtenJFN0cfK8lNSuYHg.png" /></figure><p>Check in live : <a href="https://jsbin.com/mawimehixa/1/edit?js,console">https://jsbin.com/mawimehixa/1/edit?js,console</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=972bcf67a146" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Minimalist Guide for React Component Life cycle (with examples)]]></title>
            <link>https://kaissaroj.medium.com/minimalist-guide-for-react-component-life-cycle-with-examples-2132e0d90dc1?source=rss-d9e60d34e028------2</link>
            <guid isPermaLink="false">https://medium.com/p/2132e0d90dc1</guid>
            <category><![CDATA[react]]></category>
            <category><![CDATA[lifecycle-methods]]></category>
            <dc:creator><![CDATA[Saroj Subedi]]></dc:creator>
            <pubDate>Wed, 06 Mar 2019 06:15:29 GMT</pubDate>
            <atom:updated>2019-03-06T06:15:29.795Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*YtvDr5zSJZg0Q17Y" /><figcaption>Photo by <a href="https://unsplash.com/@markusspiske?utm_source=medium&amp;utm_medium=referral">Markus Spiske</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>React component life cycle can be break down into three basic levels on the basis of methods being triggered or used.</p><ul><li>Mounting (initialization)</li><li>Update (change in props &amp; states)</li><li>Unmounting</li></ul><h3><strong>Mounting (initialization)</strong></h3><p>Main job of React is to figure out how to modify the DOM to match the components want to be rendered on the screen. For this, <strong>mounting</strong> is performed.</p><p>This level consists of 4 functions group by their running order.</p><ul><li>constructor</li><li>componentWillMount</li><li>render</li><li>componentDidMount</li></ul><h4><strong>constructor</strong></h4><p>This is first method which is called before component is mounted. If we need to initialize states or bind methods, we need to do that under constructor.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*aX-iAgAa1jVO5LSfagjjAw.png" /></figure><h4><strong>componentWillMount</strong></h4><p>This method is called after constructor. <strong>componentWillMount</strong>() is invoked just before mounting occurs. It can be useful to make final changes to component before rendering.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/688/1*EYivoQY0FRXtjKTYOD1AIw.png" /></figure><p><strong>Note</strong>: <em>It is depreciated and going to be remove after version 17. So, it’s best to move codes to constructor or componentDidMount.</em></p><h4><strong>render</strong></h4><p>render() is third method called. It returns single elements which represents component during rendering process. If there is nothing to return, then return null or undefined. If we don’t want any extra div for wrapping the elements, we can use React.Fragment to wrap the components.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*EHx60YjZvBQwI1cHBLa8Vw.png" /></figure><h4><strong>componentDidMount</strong></h4><p>This is the fourth method where we are able access component DOM nodes and elements. This method is called after mount completion.Main tasks which can be performed under this method are :</p><ul><li>timers/intervals functions</li><li>fetching data</li><li>event listeners</li><li>manipulating DOM</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*2rtV7hFnP3yZkZyIiyWWlg.png" /></figure><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fcodesandbox.io%2Fembed%2F717vw9y7q%3Ffontsize%3D14&amp;url=https%3A%2F%2Fcodesandbox.io%2Fs%2F717vw9y7q%3Ffontsize%3D14&amp;image=https%3A%2F%2Fcodesandbox.io%2Fapi%2Fv1%2Fsandboxes%2F717vw9y7q%2Fscreenshot.png&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=codesandbox" width="1000" height="500" frameborder="0" scrolling="no"><a href="https://medium.com/media/0913cef556ef926814a9784bbf1038d8/href">https://medium.com/media/0913cef556ef926814a9784bbf1038d8/href</a></iframe><h3>Update Life cycle (change in props &amp; states)</h3><p>When there is some changes in states or props, various react methods get triggered or called or used.</p><p><strong>When a component has state changed:</strong></p><ul><li>shouldComponentUpdate</li><li>componentWillUpdate</li><li>render</li><li>componentDidUpdate</li></ul><p><strong>When a component has props changed:</strong></p><ul><li>componentWillReceiveProps</li><li>shouldComponentUpdate</li><li>componentWillUpdate</li><li>render</li><li>componentDidUpdate</li></ul><h4>componentWillReceiveProps(nextProps)</h4><p>This is the first method to be called in update life cycle. This is invoked when props are passed to component instance. When components properties change, this method get called with new properties. This method allows us to check and see if new props are coming in and we can make choices based on the data.</p><p>For further information, check this example where child component receive props from parent component, when that prop get changed, then we can see <strong>componentWillReceiveProps </strong>gets called in child component.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fcodesandbox.io%2Fembed%2F9q2rjz7jow%3Ffontsize%3D14&amp;url=https%3A%2F%2Fcodesandbox.io%2Fs%2F9q2rjz7jow%3Ffontsize%3D14&amp;image=https%3A%2F%2Fcodesandbox.io%2Fapi%2Fv1%2Fsandboxes%2F9q2rjz7jow%2Fscreenshot.png&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=codesandbox" width="1000" height="500" frameborder="0" scrolling="no"><a href="https://medium.com/media/a3eb32972b716bb89adddc014bff4c7c/href">https://medium.com/media/a3eb32972b716bb89adddc014bff4c7c/href</a></iframe><h4>shouldComponentUpdate(nextProps, nextState)</h4><p>This is the second function called on properties changes and the first on state changes. By default, this method return true which means whenever there is change in properties React render new version of that component. But sometimes there will be no reason to re-render, at such circumstances, we can return false from <strong>shouldComponentUpdate </strong>method which will stop the re-render.</p><p>To be more clear about this, lets take previous example of <strong>componentWillReceiveProps </strong>and make some changes to use <strong>shouldComponentUpdate . </strong>We have input box which change makes re-render the child component. Lets add new condition, if input box have input text length more than 10, then we will not re-render child component.</p><p>OK, check this example.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fcodesandbox.io%2Fembed%2F246omv065p%3Ffontsize%3D14&amp;url=https%3A%2F%2Fcodesandbox.io%2Fs%2F246omv065p%3Ffontsize%3D14&amp;image=https%3A%2F%2Fcodesandbox.io%2Fapi%2Fv1%2Fsandboxes%2F246omv065p%2Fscreenshot.png&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=codesandbox" width="1000" height="500" frameborder="0" scrolling="no"><a href="https://medium.com/media/9936c96747ea27052d4b64c3c20ebed3/href">https://medium.com/media/9936c96747ea27052d4b64c3c20ebed3/href</a></iframe><h4>componentWillUpdate(nextProps, nextState)</h4><p>This function is similar to <strong>componentWillMount(). </strong>Only difference is that it is called every time component is re-renders. This method is called before <strong>render()</strong>.</p><p><strong>Note</strong>: <em>You cannot use this.setState() inside this method</em>.</p><h4>componentDidUpdate(prevProps, prevState)</h4><p>This method is update version of <strong>componentDidMount()</strong>. If we need to interact with 3rd party library changes, we can to that inside this method. We can perform DOM related tasks.</p><h3>Unmounting</h3><ul><li>componentWillUnmount</li></ul><h4>componentWillUnmount</h4><p>If we want to reverse any setup/tasks that we did in either <strong>componentWillMount</strong>() or <strong>componentDidMount</strong>(). Tasks like event listeners, third party library elements should be remove before leaving the UI stack.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fcodesandbox.io%2Fembed%2Fq825zm3jmj%3Ffontsize%3D14&amp;url=https%3A%2F%2Fcodesandbox.io%2Fs%2Fq825zm3jmj%3Ffontsize%3D14&amp;image=https%3A%2F%2Fcodesandbox.io%2Fapi%2Fv1%2Fsandboxes%2Fq825zm3jmj%2Fscreenshot.png&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=codesandbox" width="1000" height="500" frameborder="0" scrolling="no"><a href="https://medium.com/media/88d38445a1315907fd40428fe65e8ebc/href">https://medium.com/media/88d38445a1315907fd40428fe65e8ebc/href</a></iframe><h3>Bonus :</h3><p>There are some new methods in react component life cycle which are rarely used.</p><h4><em>static getDerivedStateFromProps(nextProps, prevState) :</em></h4><p>This is static method(only available in class level) which can be used instead of <strong>componentWillReceiveProps.</strong></p><h4>getSnapshotBeforeUpdate(prevProps, prevState) :</h4><p><strong>getSnapshotBeforeUpdate</strong> is invoked right before the most recently rendered output is committed to e.g. the DOM. It enables your component to capture some information from the DOM (e.g. scroll position) before it is potentially changed. Any value returned by this life cycle will be passed as a parameter to componentDidMount.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2132e0d90dc1" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>