<?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 Apaar Bhatnagar on Medium]]></title>
        <description><![CDATA[Stories by Apaar Bhatnagar on Medium]]></description>
        <link>https://medium.com/@apaar256?source=rss-a30ea0b59d3b------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*4NxiclX1W-guVm0Z.</url>
            <title>Stories by Apaar Bhatnagar on Medium</title>
            <link>https://medium.com/@apaar256?source=rss-a30ea0b59d3b------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Wed, 02 Dec 2026 10:37:28 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@apaar256/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[My stay in Peepalfarm, Dharamshala]]></title>
            <link>https://medium.com/@apaar256/my-stay-in-peepalfarm-dharamshala-7efeb3f0aedf?source=rss-a30ea0b59d3b------2</link>
            <guid isPermaLink="false">https://medium.com/p/7efeb3f0aedf</guid>
            <category><![CDATA[travel]]></category>
            <category><![CDATA[organic-farming]]></category>
            <category><![CDATA[farming]]></category>
            <category><![CDATA[dharamshala]]></category>
            <category><![CDATA[volunteering]]></category>
            <dc:creator><![CDATA[Apaar Bhatnagar]]></dc:creator>
            <pubDate>Fri, 07 Jan 2022 08:35:00 GMT</pubDate>
            <atom:updated>2022-01-07T08:35:00.177Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Sq0MAoX__RbpDbEeL88lSw.jpeg" /></figure><p>Peepalfarm is located in dhanotu village, dharamshala. I lived there for around 20 days and volunteered in it. My experience was fun and met a lot of new people. I stayed at a homestay near Peepalfarm. The landlord, his family were so friendly and lovely people 🤗. I was having home made food which was so delicious that I always used to end up eating more than I could 😋.</p><p>In starting I was given different departments to volunteer in like animal area, media, farming. I choose farming and I really enjoyed it. There I got the first hand experience of how farming is conducted completely organically. Of course there is much to be learnt about farming but how to do it organically is very important. Here they have not used a single chemical pesticides or insecticides for more than decades. They do not till their lands instead they cover the soil beds with cardboard or mulch it to retain the moisture and also to demote the growing of weeds.They use drip irrigation system to water the plants. It needs some setup but once done it will be ecological as well as conducive to water the plants. Weeding was always there in the farm though as these tiny weeds grow endlessly 😜. My daily around 20–30 min used to go in weeding 😓. But it was fun I must say as I was doing it all for the first time. I learnt a lot. Volunteering hours are fixed in the first half 9:15 am to 1 pm and the second half is flexible. It is not mandatory to come in the second half.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*LnC2WAGnJ-7B9-0gGJH6YQ.jpeg" /></figure><p>Peepalfarm has a range of products, do check them out at their <a href="https://shop.peepalfarm.org/shop">product</a> page. I loved the kombucha drink. It is prepared by fermenting black tea. This naturally fizzy drink is worth a try. They have many flavours to it — tamarind, Ginger Ale(😍), Pineapple(aka Tapache!!). If you want you can also make your own tapache drink at home. Peepalfarm has shared the recipe on their youtube page.Do watch it!!</p><p>The farms produce majorly goes towards consumption by the people in Peepalfarm. They grow variety of vegetables here — garlic, broccoli, cauliflower,</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*JfEGpMfMXbUEuuryL-Yq_w.jpeg" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*bIeV_AyFUNhCG2ClQCk8Ow.jpeg" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*xSnzUc22M2XBokoWjm0gbw.jpeg" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*YJWz5CmNH7bHzm0B7aF9vA.jpeg" /></figure><p>cabbage, turnip, tomatoes, brinjals, cucumber, chillies, coriander, spinach phew and there might be others I am sure I am missing out. But I experienced so much joy to have food like this just straight out of farm. Vegetables that are grown for humans and not for the market.</p><p>In our free time there are number of places in dharamshala or nearby areas to explore. Mcleodganj is such a place, it has monasteries, church where you can visit. The market here is awesome and food stalls, cafes are fun to try. I enjoyed the christmas and new year eve here. The place was a bit crowded though but of course who wants to miss those events here.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*uBYJF0QYZwXJpXl3r3N8Fg.jpeg" /><figcaption>Sunset at Mcleodganj</figcaption></figure><p>We also went to Naddi, a sunset view point. I missed the triund track this time 😓 but will love to go on it next time. One should also plan to visit bir billing, its almost 2 hr journey from dharamshala. The paragliding there is worth a try. They also offer courses in paragliding.</p><p>Overall my experience of volunteering in peepalfarm and visiting nearby places was a fun ride. Its good to see that so many people are visiting here, volunteering for it and spreading the word for it. The vision of peepalfarm, their principles is what we need at this time. I wish them all the best😇</p><p>Peepalfarm website — <a href="https://peepalfarm.org/">https://peepalfarm.org/</a></p><p>Follow me on instagram— <a href="https://www.instagram.com/apaar.bhatnagar/">https://www.instagram.com/apaar.bhatnagar/</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7efeb3f0aedf" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Intersection observers, lazy-loading, thumb image placeholders.]]></title>
            <link>https://medium.com/@apaar256/in-this-article-we-will-be-implementing-lazy-loading-of-images-using-intersection-observers-3c8ae4679099?source=rss-a30ea0b59d3b------2</link>
            <guid isPermaLink="false">https://medium.com/p/3c8ae4679099</guid>
            <category><![CDATA[react]]></category>
            <category><![CDATA[react-hook]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[lazy-loading]]></category>
            <category><![CDATA[intersection-observer]]></category>
            <dc:creator><![CDATA[Apaar Bhatnagar]]></dc:creator>
            <pubDate>Mon, 19 Oct 2020 18:59:01 GMT</pubDate>
            <atom:updated>2020-10-20T10:22:49.704Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*ZCU2SgIf4jBSmx1b" /><figcaption>Photo by <a href="https://unsplash.com/@flowforfrank?utm_source=medium&amp;utm_medium=referral">Ferenc Almasi</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>In this article, we will be implementing lazy loading of images using Intersection observers. Well, this is not an entirely new thing but we will be adding few handful tricks like first a low-quality placeholder image is loaded and then the actual image is loaded.</p><p>This makes sure that even if you are running the application on low data throughput, your user’s interest is not lost.</p><p>First we will be loading the low-quality image thumbnail, which will act as placeholder and parallelly make the request for the high resolution image. The intersection observer will make sure that your image request is entertained only when the image is actually in the viewport and thus saving the bandwidth.</p><p>Here, I will be providing the screenshots of the code that can be followed. First, lets setup the image-container that maintains the aspect-ratio.</p><p>We will be using dummy images links. We will be having two links for one image one will be of low-quality and other one is the original image.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/7cee859f1ce1d1d4f3f06eebc9af36ae/href">https://medium.com/media/7cee859f1ce1d1d4f3f06eebc9af36ae/href</a></iframe><p>Now, we will be creating our image-container which will be having access to images to load.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/848f4ef6a99692f21c9e95274a2d253a/href">https://medium.com/media/848f4ef6a99692f21c9e95274a2d253a/href</a></iframe><p>Lets start building the image container.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/81f7bc71aef1318cfad405724b8f659c/href">https://medium.com/media/81f7bc71aef1318cfad405724b8f659c/href</a></iframe><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/e697b67a0c6a1c194aaea3e3f0545539/href">https://medium.com/media/e697b67a0c6a1c194aaea3e3f0545539/href</a></iframe><p>Ok, so this will make your render something like this.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/1*8WwZbTDCrSjSsaqD6tlvxw.gif" /></figure><p>Phew!!! Ok so now we will implement the real stuff. Lets first setup our intersection observer.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/2368fdc6cba752d0ac4938e007a2e75a/href">https://medium.com/media/2368fdc6cba752d0ac4938e007a2e75a/href</a></iframe><p>If this code seems a little bit intimidating, then please try to go through the comments enclosed. I tried to explain each step.</p><p>We have used refs given by React to select each image node and add src attribute to it when the node actually comes into the viewport. If initially we had given the src attribute to the image, it would have downloaded right away, which defeats the purpose of observers.</p><p>Okk so most of the task is done. Now, we just need to hide the thumb image when the actual images loads. This is pretty much easy, we need to make sure that initially, the high resolution image opacity is zero and we will change it to 1 when the image loads and we need to hide the current thumb image.</p><p>Recall in our style.scss file, add these styles to the img tag.</p><pre>&amp;.thumb-image {<br>    filter: blur(10px);<br>}<br>&amp;.high-res {<br>    opacity: 0;<br>}</pre><p>Now, add this code to your image-container.jsx</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/66cb1053ea132b57c31211f321594183/href">https://medium.com/media/66cb1053ea132b57c31211f321594183/href</a></iframe><p>You can add more images to your images.json file.</p><p>Finally your application looks like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/1*W06RTsTO7HF-azGiFzFsEA.gif" /></figure><p>If you guys have followed till now and able to implement this functionality in your own application then kudos to you.</p><p>Here is the github link to the project.</p><p><a href="https://github.com/abha57/image-lazy-load-with-thumb">abha57/image-lazy-load-with-thumb</a></p><p>And here is the codesandbox link</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fcodesandbox.io%2Fembed%2Fgifted-cache-31gym&amp;display_name=CodeSandbox&amp;url=https%3A%2F%2Fcodesandbox.io%2Fs%2Fgifted-cache-31gym&amp;image=https%3A%2F%2Fcodesandbox.io%2Fapi%2Fv1%2Fsandboxes%2F31gym%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/7b3f7e4f6f2e43b7119378b5972d21dd/href">https://medium.com/media/7b3f7e4f6f2e43b7119378b5972d21dd/href</a></iframe><p>Please provide your feedback on the same.</p><p>Connect with me on linkedin: <a href="https://www.linkedin.com/in/apaar-bhatnagar-a1158088/">https://www.linkedin.com/in/apaar-bhatnagar-a1158088/</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3c8ae4679099" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Two way data binding: Vanilla JS, Observer pattern]]></title>
            <link>https://medium.com/@apaar256/two-way-data-binding-vanilla-js-observer-pattern-879248091851?source=rss-a30ea0b59d3b------2</link>
            <guid isPermaLink="false">https://medium.com/p/879248091851</guid>
            <category><![CDATA[data-binding]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[observer-pattern]]></category>
            <category><![CDATA[vanillajs]]></category>
            <category><![CDATA[two-way-data-binding]]></category>
            <dc:creator><![CDATA[Apaar Bhatnagar]]></dc:creator>
            <pubDate>Wed, 09 Sep 2020 15:23:41 GMT</pubDate>
            <atom:updated>2020-09-12T11:13:24.869Z</atom:updated>
            <content:encoded><![CDATA[<p>Popular frameworks out there like Angular, Vue implements two-way binding under the hood. But its always helpful to know what’s going on inside. In this article, we will try to implement two way data binding using vanilla JS and observer pattern.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*FE6bCQ0tkOS43WCR" /><figcaption>Photo by <a href="https://unsplash.com/@mr_vero?utm_source=medium&amp;utm_medium=referral">Irvan Smith</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>Well this wont be a very heavy implementation of two way binding, but it will surely give you an insight into how it is achieved in popular frameworks. Also the same can be implemented in a number of ways.</p><p>First lets define an input field where we add a custom data-bind attribute to which we will perform the binding.</p><figure><img alt="sample input field." src="https://cdn-images-1.medium.com/max/974/1*aWlnxURuS3mJc310POSx4w.png" /></figure><p>Note the span element where we have attached the same attribute value. This we will use to update the value of this span element.</p><p>Next, lets write some code for the elements that have this data-bind attribute.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/986/1*0w7qtgCXzywWOvISMc3KPA.png" /></figure><p>Note that here we will be taking the value from an input field(our view), and updating a span element’s value(which is bounded to a model). Now, comes the main part, to implement the observer pattern.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/993/1*YfCgJVS7GW2jVcPa8Bk36w.png" /></figure><p>Let me try to walk you through the pattern step-by-step. Our observer pattern has three main methods: updateState — to update the local state(our model), notifyObservers(to notify all observers) and addObserver — to add observers to our pattern.</p><p>What eventually going to happen is that we call for the update state method which will update the state and then notify all observers by passing them with the updated state everytime.</p><p>Lets use this pattern inside our small demo.</p><pre>const dataBindObserver = new Observer();</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/940/1*CEb3p-mu9xJA-HpC3r40Vg.png" /></figure><p>So, here we are updating the observer’s state with the current value of the input. We are making sure that each inputs value is preserved using the unique data-bind attribute we passed to it.</p><p>Now, lets add the observer to listen to the changes inside the state.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/979/1*uZHKdLBVmuC34M_LlhwuPA.png" /></figure><p>The state we will be getting will be the updated state with the changed values of inputs. Then we can simply change the content of any element which is expected to reflect the change.</p><p>Now let’s add the functionality for changing our model and in turn changing the view. Suppose our model(in this case state) changes due to some user action like click of a button or some api call etc. Our observer should be intelligent enough to detect the change and inturn reflect that change on our view. Lets add a button in our html and attach click event to it.</p><pre>&lt;div&gt;&lt;button onclick=&quot;resetAll()&quot;&gt;Reset all&lt;/button&gt;&lt;/div&gt;</pre><pre>const resetAll = () =&gt; {<br>  dataBindObserver.updateState({});<br>};</pre><p>Here we are update the state with an empty object. Lets change our observer to handle this kind of change.</p><pre>const initialState = {<br>  name: &#39;This is the  initial state.&#39;,<br>  surname: &#39;This is the initial state.&#39;<br>};</pre><pre>const Observer = function() {<br>   ...<br>  this.updateState = updateObj =&gt; {<br>    if (Object.keys(updateObj).length === 0) {<br>      this.state = {<br>         ...initialState<br>      };<br>    } else {<br>       Object.keys(updateObj).map(key =&gt; {<br>          this.state = {<br>             ...this.state,<br>             [key]: updateObj[key]<br>          };<br>       });<br>    }<br>   this.notifyObservers();<br> };<br>   ...<br>}</pre><p>And finally when we are observing the state changes, we need to add observers on our input elements as well.</p><pre>...</pre><pre>if (!element.type) {<br>  dataBindObserver.addObserver(state =&gt; {<br>    if (state[stateVar]) {<br>      element.innerHTML = state[stateVar];<br>    }<br>  });<br>} else {<br>   dataBindObserver.addObserver(state =&gt; {<br>     if (state[stateVar]) {<br>       element.value = state[stateVar];<br>     }<br>   });<br>}</pre><pre>...</pre><p>Here is the small recording of working example.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/1*eQUTb8PFHhCQisOqfVPPsQ.gif" /></figure><p>Here I am attaching the <a href="https://github.com/abha57/two-way-binding">github</a> repo for quick reference.</p><p>If you find this article helpful, please clap or you can share your feedback as well in the comments section.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=879248091851" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Migrating React v15.5 to v16.8 and react router v3 to v5]]></title>
            <link>https://medium.com/@apaar256/migrating-react-v15-5-to-v16-8-and-react-router-v3-to-v5-b9426aa7c305?source=rss-a30ea0b59d3b------2</link>
            <guid isPermaLink="false">https://medium.com/p/b9426aa7c305</guid>
            <category><![CDATA[react-router]]></category>
            <category><![CDATA[react]]></category>
            <category><![CDATA[querystring]]></category>
            <category><![CDATA[react-hook]]></category>
            <category><![CDATA[code-splitting]]></category>
            <dc:creator><![CDATA[Apaar Bhatnagar]]></dc:creator>
            <pubDate>Mon, 07 Oct 2019 07:27:39 GMT</pubDate>
            <atom:updated>2019-10-07T07:27:39.668Z</atom:updated>
            <content:encoded><![CDATA[<h3>Migrating React v15.5 to v16.8 and react-router v3 to v5</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*d1Qh6E6OUtsg3Nrl" /><figcaption>Photo by <a href="https://unsplash.com/@gallarotti?utm_source=medium&amp;utm_medium=referral">Francesco Gallarotti</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>So our team was tasked with migrating our codebase from react v15.5.4 to react v16.8.6 and react-router v3.0.2 to 5.0.0. This post might help you with the migration and it also includes other packages that you might need to update.</p><p>So we first started with changing our package.json and see if anything breaks. As expected migration of react and react-dom version was smooth but react-router gave us a hard time. The class-based components that we had written before worked fine for us. <br>Lifecycle methods like componentWillMount, componentWillUpdate, and the most misunderstood method componentWillReceiveProps will continue to work until version 17 but we have added UNSAFE_ prefix, as stated in React docs only the new “UNSAFE_” lifecycle names will work from v&gt;17.x forward. There is a whole cli for it <a href="https://reactjs.org/blog/2018/03/27/update-on-async-rendering.html">here</a>.</p><p>In react-router v3, we used to define our routes in the beginning of, say the parent, so the app’s route.js looked like this:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/63226694064a22842e98080664b90504/href">https://medium.com/media/63226694064a22842e98080664b90504/href</a></iframe><p>The child routes would have something similar to load their own container components, index routes and child routes. You can notice that we are specifying at the beginning of the parent component that what would be the default routes and what would be the child routes.</p><p>Now when we rewrite our app routes.js, we just specify the first level routes that will be there. So our routes.js became something like:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/8cf7784387451ad9fd2d836d62f7b2d4/href">https://medium.com/media/8cf7784387451ad9fd2d836d62f7b2d4/href</a></iframe><p>Here we have added the lazy loading of child routes so that all the modules are not fetched concurrently but only when a particular route is requested. Through this, we achieved “code-splitting”. In react-router 3, code splitting was done through getComponent, getIndexRoute, getChildRoutes.</p><p>As you can see we have added Suspense which helps to render a fallback component till our route module is requested from the server. If you want to learn more about code splitting you can learn it <a href="https://tylermcginnis.com/react-router-code-splitting/">here</a>.</p><p>You can also define your Error boundaries which makes sure that if your requested route fails then how the error would be handled. You can have multiple error boundaries in your app or a single error boundary at the root level. Error Boundary helped us to catch error inside any deeply nested child component and we displayed it with a fallback UI.</p><p>Now when our root level routes are defined, we need to dive inside these routes and do routing for their subsequent child routes. But first let us understand how it was done in router v3. Suppose our Shopping route has two child routes: shop-shirts, shop-pants, and the shopping container folder structure was:</p><pre>@shopping/index.jsx,</pre><pre>@shopping/routes.js,</pre><pre>@shopping/shop-shirts,</pre><pre>    | routes.js<br>    | index.jsx</pre><pre>@shopping/shop-pants</pre><pre>    | routes.js<br>    | index.jsx</pre><p>The @shopping/routes.js looked like:</p><pre><br>import { ShoppingShirtsRouteConfig } from &#39;pages/@shopping/shopping-shirts/routes&#39;;<br>import { ShoppingPantsRouteConfig } from &#39;pages/@shopping/shopping-pants/routes&#39;;<br><br>const ShoppingShirtsRoute = Object.assign({ path: &#39;shirts&#39; }, ShoppingShirtsRouteConfig);<br>const ShoppingPantsRoute = Object.assign({ path: &#39;pants&#39; }, ShoppingPantsRouteConfig);<br><br>export const ShoppingRouteConfig = {<br>  getComponent(location, cb) {<br>    // here goes the @shopping/index.jsx container<br>  },<br>  getIndexRoute(location, cb) {<br>    // Here goes the ShoppingPantsRouteConfig<br>    });<br>  },<br>  getChildRoutes(partialNextState, callback) {<br>    callback(null, [<br>      ShoppingShirtsRoute,<br>      ShoppingPantsRoute<br>    ]);<br>  }<br>};</pre><p>The ‘pages/@shopping’ provides the index.jsx file which is the container of the current route. The route ‘/pants’ is made the default route by ‘getIndexRoute’. Inside the pants route, we then send the children elements through React.cloneElement because in this case, we didn’t know what our children would be like. So the shopping-pants.jsx would be something like:</p><pre>return (<br>    React.cloneElement(children, {<br>    //few extra props<br>    })<br>);</pre><p>Now in router v5, we tend to perform declarative routing which means that we don’t give our parents the child routes right at the beginning of the parent container but conditionally inside the render of our parent container. So the shopping/routes.js would become:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/05eec90a125b9ba4c970447348eb16f4/href">https://medium.com/media/05eec90a125b9ba4c970447348eb16f4/href</a></iframe><p>And our shopping-pants.jsx would become:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/128383f495164791923fc2756fe229fd/href">https://medium.com/media/128383f495164791923fc2756fe229fd/href</a></iframe><p>So instead of React.cloneElement we are declaring our routes and specifying our router which component to load on a particular path. Also, note that the extra props that we were previously sending through React.cloneElement are now passed inside render function that &lt;Route&gt; gives us.</p><p>So this was for the routing. Any nested level route you can handle like this. Now there was an api like browserHistory which was available in the router v3, using it we could change the url of our browser tab.</p><p>In router v5, no browserHistory is available but the &lt;Route&gt; has been made more powerful. It offers props like history, match, location to all the components it renders. For instance,</p><pre>&lt;Route path={`${match.url}/pants`} component={ShoppingPantsRoute} /&gt;</pre><p>The ShoppingPantsRoute will have access to props history, match, location. These props are in sync with the browser tab, so no need to worry about their updated values. The history prop works just like browserHistory. You can push, replace with props.history.</p><p>Previously, in router v3 we used to extract query params from location props. But in router v5, location.query is no longer available, location.search is available. If you have <a href="https://www.npmjs.com/package/qs">qs</a> library in your project or <a href="https://github.com/sindresorhus/query-string">queryString</a>, you can do:</p><pre>const searchString = props.location.search.slice(1);</pre><pre>const queryParams = qs.parse(searchString);</pre><p>Here slice is just to remove the ‘?’ in the search.</p><p>We also updated other packages like:</p><pre>&quot;react-dom&quot;: &quot;^15.5.4&quot; to &quot;react-dom&quot;: &quot;^16.8.6&quot;<br>&quot;react-modal&quot;: &quot;^1.7.7&quot; to &quot;react-modal&quot;: &quot;^3.10.1&quot;<br>&quot;react-redux&quot;: &quot;^5.0.6&quot; to &quot;react-redux&quot;: &quot;^7.1.0&quot;<br>&quot;react-tabs&quot;: &quot;^2.2.1&quot; to  &quot;react-tabs&quot;: &quot;^3.0.0&quot;<br>&quot;redux&quot;: &quot;3.7.0&quot; to &quot;redux&quot;: &quot;^4.0.1&quot;<br>&quot;redux-saga&quot;: &quot;^0.16.0&quot; to &quot;redux-saga&quot;: &quot;^1.0.3&quot;</pre><p>Okay, Guys, that’s it from my side. I hope you find this helpful in your version migration(if you are planning one ;-) ).</p><p>Also please share your queries or problems that you might face.</p><p>Thanks to <a href="http://medium.com/@khandelwalsarthak81">Sarthak Khandelwal</a> for helping in the migration of versions and code-splitting.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b9426aa7c305" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>