score:0
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)
}
Source: stackoverflow.com
Related Query
- React.js: useEffect with window resize event listener not working
- React Router with custom history not working
- Extending styles with styled-components not working
- React router v4 not working with Redux
- onmouseover not working with React.js
- Formik & yup form validation not working as expected with VirtualizedSelect
- React Error Boundaries not working with React
- React JS not working with Internet Explorer 9
- React Native Image Not Working with specific URL
- React hook useRef not working with styled-components and typescript
- Some Tailwind styles not working in production with Next.js
- Webpack module federation is not working with eager shared libs
- Tailwindcss not working with next.js; what is wrong with the configuration?
- Connect not working with StateLess component in Redux-react
- Fetch API not working with localhost/127.0.0.1
- import syntax not working with webpack
- Material UI v5 server side rendering css order not working with gatsby
- Paste from clipboard not working with React Native on iOS simulator
- Google analytics with react is not working
- require function not working with image in react
- Setting a default value with react-select not working
- Window is not defined after a build with Webpack
- window is not defined - react-draft-wysiwyg used with next js (ssr)
- react-hook-form reset is not working with Controller + antd
- Azure App service not working with custom routing in React-Redux web app - need wildcard virtual directories?
- Search not working with React material-table using remote data
- next/image not working with props as image source
- connect redux function is not working with react-native
- Font Awesome 5 icons not working with React ("Could not find icon" error)
- Mui v5 styleOverrides not working with themes
More Query from same tag
- how to call function with parameter in JSX?
- Deprecation warning using this.refs
- React Boostrap edit fields does not respect col-N className
- How to get FileInput field to work in react-admin 3.2.3
- Responsive navigation menu with React and Bootstrap - hamburger isn't working
- Huge freezes when rendering long selects in React
- material ui Select handleChange
- video-react attribute width and height is not working
- Feed native Javascript objects to React
- react js render differnet component based on button click
- React - event.target is undefined when trying to filter React-select options
- React Router + Animation libraries problems: components won't animate before unmounting with react-router-dom
- How to Access package.json data inside the application?
- Mongoose - Updating a subdocument using findOneAndUpdate
- google auth and firebase persistence
- External script with classes in React
- ToggleCollapsed on imported sidebar reactjs component
- How to check Dynamic Checkbox in React JS
- Iterating through an arrary which is nested in an object which is nested in an array React
- Using context doesnt update state in react?
- Reflux actions global debugging
- How to import var RouteHandler = require('react-router').RouteHandler; on ES6?
- Yarn Workspaces, workspace does not emit errors or warnings
- "Anonymous" HTML elements added while consolidating React Providers
- sum duplicate array values and then storing them [react js]
- Callback functions not properly executing in Action Creator
- Restore scroll position in React Hooks with useRef is shaky
- React Component access Props
- Material Table grouped view add row doesn't show grouped field
- React projects npm start not working says localhost rufused to connect