epicweb-dev / restore-scroll

🌀 Restore scroll position of elements on page navigation
https://github.com/epicweb-dev/restore-scroll
241 stars 4 forks source link

Usage with Remix #5

Open na2hiro opened 3 months ago

na2hiro commented 3 months ago

When I use in my Remix app, I get an error saying it's not wrapped with data router. If I copy paste ElementScrollRestoration and modify import from react-router-dom to @remix-run/react, it works.

useNavigation must be used within a data router. See https://reactrouter.com/routers/picking-a-router.

Can this library cover Remix usage as well?

Versions and setup

kentcdodds commented 3 months ago

I'm using it with Remix currently and haven't run into that problem. Could be a new version issue. Definitely open to a pull request that supports both or even makes it a bit more generic if possible.

na2hiro commented 3 months ago

Probably the upcoming release of React Router v7 will let us import from react-router everywhere including Remix apps and fix this

https://remix.run/blog/merging-remix-and-react-router