<?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 Nasir Uddin on Medium]]></title>
        <description><![CDATA[Stories by Nasir Uddin on Medium]]></description>
        <link>https://medium.com/@nasir?source=rss-34f93c384e82------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*rVA212gKtFlz_MebZsvYow.jpeg</url>
            <title>Stories by Nasir Uddin on Medium</title>
            <link>https://medium.com/@nasir?source=rss-34f93c384e82------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 17 Nov 2026 20:15:34 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@nasir/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[Reset Scroll position on change of Routes — React]]></title>
            <link>https://medium.com/@nasir/reset-scroll-position-on-change-of-routes-react-a0bd23093dfe?source=rss-34f93c384e82------2</link>
            <guid isPermaLink="false">https://medium.com/p/a0bd23093dfe</guid>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[history]]></category>
            <category><![CDATA[front-end-development]]></category>
            <category><![CDATA[reactjs]]></category>
            <category><![CDATA[redux]]></category>
            <dc:creator><![CDATA[Nasir Uddin]]></dc:creator>
            <pubDate>Sat, 01 Sep 2018 07:17:37 GMT</pubDate>
            <atom:updated>2018-09-01T07:17:37.451Z</atom:updated>
            <content:encoded><![CDATA[<h3>Reset Scroll position on change of Routes — React</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*gwHDjH4OxD-urxYRqRqmXw.jpeg" /></figure><p>I am working with ReactJS from a while. During this time I am working a project where I found a common issue of React-router. I am working to create front-end of a website with ReactJS. The site contains long pages including homepage. The issue was when we scrolled to the bottom and click on any links or menu item to route another page, the next page always on the previous page scroll position. That’s really annoying. That isn’t ideal behavior as the user expects to go to the top of the page. So let’s look at how I resolved the issue.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/36e52ae1877ca6e0bc5c39376c94af15/href">https://medium.com/media/36e52ae1877ca6e0bc5c39376c94af15/href</a></iframe><p>The above is an example of a router for a project I am putting together. With this router setup, whenver we scroll to bottom of home page and navigate to other page like About route, I remain at the same scroll position from the Home route.</p><p>We can change the page scroll position with this js code snippet. <strong><em>window.scrollTo(0,0)</em></strong></p><p>We can achive the behaviour with react history api.</p><p>Lets make an update to our history to like this</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/891bc64322e66214e9d074737914a2f8/href">https://medium.com/media/891bc64322e66214e9d074737914a2f8/href</a></iframe><p>We can add those line to our App.jsx after creating history to update our experience when <strong><em>navigate between routes</em></strong>.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/fbca1fe223dfd990831c32bb27b5ce16/href">https://medium.com/media/fbca1fe223dfd990831c32bb27b5ce16/href</a></iframe><p>So with this update, whenever history <strong>API </strong>listen any change in router path, the window’s <em>scroll position</em> is reset to <strong>0,0</strong> providing the expected behavior for the user.</p><p>I am open to other suggestions to address this issue. I am always interested in feedback.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a0bd23093dfe" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>