-
What version of React Router are you using?6.6.1 Steps to ReproduceHi i startup new project with react-router v6.6.1, and i implement submit with useSubmit or fetcher.submit. (test both) when i submit, action doesn't redirect so same path is remaining, but when action is finish scroll position reseted. I also read official doc, issue and pr but i can't find fitting in. https://reactrouter.com/en/main/components/scroll-restoration i tried this but notting different. Expected BehaviorAfter submit, action result arrived to useActionData and scroll position have to be remain Actual BehaviorIn the real world, scroll reset to top even it there is no page navigation or redirection |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
Hi, i solve this problem. I thought it was bug, but i found the code that make this problem // root.tsx
...
const params = useParams();
useEffect(() => {
window.scrollTo({
top: 0,
// behavior: "smooth"
});
}, [params]);
... my coworker wrote this code to reset position when navigate, but it cause the side effect(after submit position reset), so if there are somebody having trouble like me, have a look for your component tree :) |
Beta Was this translation helpful? Give feedback.
Hi, i solve this problem. I thought it was bug, but i found the code that make this problem
my coworker wrote this code to reset position when navigate, but it cause the side effect(after submit position reset), so if there are somebody having trouble like me, have a look for your component tree :)