Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: HashRouter need to wrapped twice #11870

Closed
shalev312 opened this issue Aug 3, 2024 · 1 comment
Closed

[Bug]: HashRouter need to wrapped twice #11870

shalev312 opened this issue Aug 3, 2024 · 1 comment
Labels

Comments

@shalev312
Copy link

What version of React Router are you using?

6.26.0

Steps to Reproduce

Create a Component that uses react-router functionality (In a Outsource library)
Config project to work in react-router
Wrapped it with a HashRouter
Use the Component (React project)
Run it
Failed to run, Error in the console of 'useLocation() may be used only in the context of a component.'

Expected Behavior

The Outsource Component should 'know' about the parent HashRouter wrapper, and not fail to run.

Actual Behavior

Right now throw an exception.

If I wrap the library and the project in 2 HashRouter (One for each one), it can run (What it is not supposed to), but a kind of weird behavior happened (With the state of the URL params)

** Only one instance of the library

Screenshot 2024-08-04 at 1 40 49
@shalev312 shalev312 added the bug label Aug 3, 2024
@timdorr
Copy link
Member

timdorr commented Aug 5, 2024

This is likely something with how the app is being built and bundled, resulting in two instances of the library. Separate instances of some key internal variables is the reason you would get this message, so something about your build process is likely resulting in this. This isn't a bug in the library.

@timdorr timdorr closed this as not planned Won't fix, can't repro, duplicate, stale Aug 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants