scroll to top on react react-router-dom page change

I’m using react-router-dom for implementing routing of my reactjs App!
but I have an issue with this , in which I can’t find any working solution for scroll to top on page changing. can any body help me???

here is my routing piece of code:

    <BrowserRouter  basename={basename}> 
                    <MobilePage hasNav navType="primary" exact path={`/restaurant`} component={VendorList} />
                    <MobilePage hasNav navType="primary" path={`/restaurant/:vendorCode`} component={VendorDetails} /> 

36 thoughts on “scroll to top on react react-router-dom page change”