Fix React Router v6: "A <Route> is only ever to be used as the child of <Routes> element"
React Router v6 removed <Switch> in favor of <Routes>, and replaced the component/render props with the JSX "element" prop.
Invariant failed: A <Route> is only ever to be used as the child of <Routes> element
Quick Fix Checklist
- Replace all <Switch> tags with <Routes>
- Change <Route path="/home" component={Home} /> to <Route path="/home" element={<Home />} />
- Wrap all <Route> definitions directly inside <Routes>