ViteJS - Uncaught Error: useRoutes() may be used only in the context of a <Router> component
See original GitHub issueWhat you were expecting: react-admin should render as expected
What happened instead: react-router does not render any routes, and instead throws an exception:
Uncaught Error: useRoutes() may be used only in the context of a <Router> component
Steps to reproduce:
- Set up a new Vite project using
react-ts
template - Follow tutorial to set up a react-admin component
- Launch app
Related code:
- Preferably, a CodeSandbox forked from
- A link to a GitHub repo with the minimal codebase to reproduce the issue
insert short code snippets here
Other information:
Environment
- React-admin version:
- Last version that did not exhibit the issue (if applicable):
- React version:
- Browser:
- Stack trace (in case of a JS error):
Uncaught Error: useRoutes() may be used only in the context of a <Router> component.
invariant index.tsx:24
useRoutes index.tsx:642
Routes index.tsx:344
React 12
unstable_runWithPriority scheduler.development.js:468
React 4
unstable_runWithPriority scheduler.development.js:468
React 3
workLoop scheduler.development.js:417
flushWork scheduler.development.js:390
performWorkUntilDeadline scheduler.development.js:157
js scheduler.development.js:180
js scheduler.development.js:645
__require chunk-CEDYW5NB.js:11
js index.js:6
__require chunk-CEDYW5NB.js:11
React 2
__require chunk-CEDYW5NB.js:11
js React
__require chunk-CEDYW5NB.js:11
<anonymous> react-dom:1
index.tsx:24:19
Issue Analytics
- State:
- Created a year ago
- Reactions:1
- Comments:17 (6 by maintainers)
Top Results From Across the Web
React Router V6 - Error: useRoutes() may be used only in the ...
After saving I am getting the following error: Error: useRoutes() may be used only in the context of a component. I am wondering...
Read more >useRoutes() may be used only in the context of Router ...
The error "useRoutes() may be used only in the context of a Router component" occurs when we try to use the useRoutes hook...
Read more >uncaught [error: useroutes() may be used only in the context of ...
The issue here is that you are specifying two different versions. The router you are using is from v5, but the Routes and...
Read more >React Router V6 - Error: useRoutes() may be used only in the ...
Coding example for the question React Router V6 - Error: useRoutes() may be used only in the context of a component-Reactjs.
Read more >Is using useRoutes instead of the OG way bad in any way?
22 votes, 13 comments. import React, { Fragment } from "react"; import { useRoutes } from "react-router-dom"; import LoginScreen from…
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Not yet. For now I’m staying with fixed
react-router-dom: 6.3.0
Thanks @septentrion-730n . Will investigate a bit more on my end. Appreciate the quick turnaround!