score:0

Accepted answer

found out it is possible to disable the window.scroll(0, 0) apparently built into gatsby, using this guide: https://www.gatsbyjs.org/packages/gatsby-plugin-transitions/?=gatsby-plugin-transitions

install the transition plugin:

npm install --save yarn add gatsby-plugin-transitions gatsby-plugin-layout react-spring react react-dom

(not actually sure how many of them is actually needed to simply disable the auto scroll).

with this code in gatsby-browser.js:

exports.shouldupdatescroll = () => {
  return false;
};

score:0

componentdidmount executes only works on initial render, you should use componentdidupdate which will execute on every re-render,

componentdidupdate(){
   window.scrollto(0, 240)
}

Related Query

More Query from same tag