page is loading from previous page scroll in reactjs

JavaScript
//this piece of code will resolve this issue. in Reactjs.
componentDidMount() {
  window.scrollTo(0, 0)
}
Source

Also in JavaScript: