score:0
i had this same issue with react-router v6 and using the following instead of window.scrollto(0, 0) worked for me:
useeffect(() => {
document.body.scrollto(0, 0);
});
score:2
try grabbing document.documentelement
or another specific element instead of window
.
const location = uselocation();
uselayouteffect(() => {
document.documentelement.scrollto(0, 0);
}, [location.pathname]);
Source: stackoverflow.com
Related Query
- React router navigation does not work
- React Router Link Right Click does not work
- Although everything is fine, React Router does not work
- React router NavLink activeClassName does not work with redux and styled components
- window.location does not work with react app using react router 4
- React router Redirect does not work when route comes from another component
- Link props when passed does not work when browser back and forth is clicked React router v4
- Why react router does not work with redux?
- react router changing to current page with different params does not work
- My react router does not work on some routes
- NavLink active styling does not work | React Router
- This react onClick does not work is this Router Link wrong?
- React router does not work correctly when used with react hooks?
- React Router - Nesting routes does not seem to work
- why does my react router links work in drawer but not header
- React router v6 useNavigate does not work with redux dispatch
- React Router with path like /list/:page does not work on reload
- React router 4 does not update view on link, but does on refresh
- React Router work on reload, but not when clicking on a link
- Maxlength does not work React Js
- React css transition does not work correctly
- WebStorm auto completion does not work for React js
- react router relative link does not link properly
- Basename does not seem to be taken into account with matchPath in react router
- this.node.contains does not work if this.node is a ref to react component
- React - zIndex does not work
- React Formik does not work with number input
- React - component in seperate script does not work
- autoFocus on input when opening modal does not work - React Bootstrap
- Firebase: Invisible reCaptcha does not work in React JS
More Query from same tag
- Reactjs -- making api request based on check/uncheck of checkbox not understanding properly
- Turning Vanilla Javascript into React app in Components
- Axios.put ReactJS
- Invalid Host Header when ngrok tries to connect to React dev server
- React Router - Specify parent component for unrelated routes
- How to transpile node_modules folder using just babel 7?
- Passing Functional Components to React Spring's useTransition
- NextJS: TailwindCSS not working in production
- Writing tests for React JS
- Is it possible for a component to know where it was "implemented" vs "rendered"
- Why is this is undefined when mocking event in React unit testing, using sinon.spy to mock function and enzyme.shallow render for React Component?
- Why is `npm init react-app` using yarn as default? (npm V6.14.5)
- CloudFront Error: This XML file does not appear to have any style information associated with it
- ReactJS table diff span highlight toggle
- How to visualize a time series in react with hooks
- Why does the state update but I can't access it via hooks in React?
- Is it correct to use await setState()?
- FineUploader not working after first upload
- Dynamically change image source based on boolean value
- Upload Multiple Image in React using axios
- How to use custom components in react-markdown
- Disable submit button if element found in array in react
- How do I grab the first character of an object from a passed in prop?
- How can I store icons into my local storage?
- What method of render adds to the DOM?
- Checkbox in React Calculator
- Type argument at moment of use
- Create Antd Tree based on checked Node of another Antd Tree
- setState inside constructor not working properly: ReactJS
- Npm @babel/types error in react typescript