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]: Multiple memory routers cannot be used independently at the same time #11292

Closed
hungtcs opened this issue Feb 21, 2024 · 3 comments
Closed
Labels

Comments

@hungtcs
Copy link

hungtcs commented Feb 21, 2024

What version of React Router are you using?

v6.22.1

Steps to Reproduce

I am using in-memory routing to manage view state in a web component,
and when I create multiple instances of the same web component,
I realize that the in-memory routing cannot be used independently.

  1. Open the test project at https://stackblitz.com/edit/github-ny2pod?file=src%2Fmain.tsx
  2. I used RouterProvider in App and created two App components in main.ts.
  3. When switch the route of the first app, the route of the second app switches as well, but they are different Memory Router instances.

Expected Behavior

  1. Each memory route created through RouterProvider and createMemoryRouter should be able to be used independently of each other.

Actual Behavior

  1. When one of the routes is switched, the other one is switched with it and cannot be used independently
@hungtcs hungtcs added the bug label Feb 21, 2024
@brophdawg11
Copy link
Contributor

You're using the same router instance in both apps - you should instead create a different router instance for each app: https://stackblitz.com/edit/github-ny2pod-82jayz

@brophdawg11 brophdawg11 closed this as not planned Won't fix, can't repro, duplicate, stale Feb 28, 2024
@hungtcs
Copy link
Author

hungtcs commented Feb 29, 2024

Sorry for the stupid question, I made a basic mistake.

@brophdawg11
Copy link
Contributor

Don't be sorry! We all make mistakes!

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