<ScrollRestoration>
This component will emulate the browser’s scroll restoration on location changes after loaders have completed. This ensures the scroll position is restored to the right spot, at the right time, even across domains.
You should only render one of these, right before the <Scripts/>
component.
import {
ScrollRestoration,
Scripts,
} from "@remix-run/react";
export default function Root() {
return (
<html>
<body>
{/* ... */}
<ScrollRestoration />
<Scripts />
</body>
</html>
);
}
React Router <ScrollRestoration/>
This is a wrapper around React Router
For advanced usage, see the React Router ScrollRestoration docs.