remix-run / history

Manage session history with JavaScript
MIT License
8.29k stars 961 forks source link

Is it possible to access the history bundled into React Router? #950

Closed tom-ricci closed 2 years ago

tom-ricci commented 2 years ago

I need to use <HistoryRouter/>, but on the RR docs it says:

This API is currently prefixed as unstable because you may unintentionally add two versions of the history library to your app, the one you have added to your package.json and whatever version React Router uses internally. If it is allowed by your tooling, it's recommended to not add history as a direct dependency and instead rely on the nested dependency from the react-router package. Once we have a mechanism to detect mis-matched versions, this API will remove its unstable prefix.

Is it possible to import the history package used in React Router to prevent this? Otherwise is there any way to work around this issue?

Also, if there's no way to prevent this problem, is there any work being done on the issue? I'd be interested in contributing to it if needed.

tom-ricci commented 2 years ago

It turns out importing "history" will work as both RR and RR-DOM require it, meaning it gets brought up to the root of node_modules and is importable without specifying it in the package.json. Closing now.