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

[v6] Can't use useRoutes hook with Router component #7541

Closed
kcsujeet opened this issue Aug 4, 2020 · 4 comments
Closed

[v6] Can't use useRoutes hook with Router component #7541

kcsujeet opened this issue Aug 4, 2020 · 4 comments

Comments

@kcsujeet
Copy link

kcsujeet commented Aug 4, 2020

Version

6.0.0-beta.0

Steps to reproduce

  • import Router from 'react-router-dom' instead of BrowserRouter

  • use useRoutes hook to build routes object as shown here

Expected Behavior

Everything should work fine

Actual Behavior

Getting this error instead Error: useRoutes() may be used only in the context of a < Router > component

@kcsujeet kcsujeet changed the title Can't use useRoutes hook with Router component [v6] Can't use useRoutes hook with Router component Aug 4, 2020
@timdorr
Copy link
Member

timdorr commented Aug 4, 2020

You have to provide the location prop to Router in v6. It no longer accepts a history.

@timdorr timdorr closed this as completed Aug 4, 2020
@knuxbbs
Copy link

knuxbbs commented Jan 12, 2021

You have to provide the location prop to Router in v6. It no longer accepts a history.

@timdorr where's the guidance about this? Here you pointed to the same workaround of the previous versions, that is "create a history instance and pass that as a prop to a Router".

@MrBirb
Copy link

MrBirb commented Feb 22, 2021

@knuxbbs Have you found a solution to this lol?

@knuxbbs
Copy link

knuxbbs commented Feb 28, 2021

@knuxbbs Have you found a solution to this lol?

Unfortunately no. I think it depends on #7586.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants