I am starting with React and trying to separate the routes into their respective files. I am using react router v6.
So I want to import the admin routes in my routes.jsx like this:
import React from 'react';
import {
BrowserRouter, Routes, Route,
} from 'react-router-dom';
import AdminRoutes from './admin/adminRoutes';
const routes = () => (
<BrowserRouter>
<Routes>
<AdminRoutes />
<Route path="/home" element="User template" />
<Route path="/" element="Login Template" />
<Route path="/register" element="Register Template" />
</Routes>
</BrowserRouter>
);
export default routes;
and in my adminRoutes.jsx I have:
import React from 'react';
import { Route } from 'react-router-dom';
const adminRoutes = () => (
<Route path="admin/*">
<Route path="countries" element="countries" />
<Route path="tournaments" element="Tournaments" />
</Route>
);
export default adminRoutes;
I get the error:
Error: [adminRoutes] is not a < Route> component. All component children of < Routes> must be a < Route > or < React.Fragment >