скрипт выдает ошибку [Navigate] is not a <Route> component. All component children of <Routes> must be a <Route> or <React.Fragment>
import React, {useContext} from 'react';
import {Routes, Route, Navigate} from 'react-router-dom'
import {authRoutes, publicRoutes} from "../routes";
import {SHOP_ROUTE} from "../utils/consts";
import {Context} from "../index";
import {observer} from "mobx-react-lite";
const AppRouter = observer(() => {
const {user} = useContext(Context)
console.log(user)
return (
<Routes>
{user.isAuth && authRoutes.map(({path, Component}) =>
<Route key={path} path={path} component={Component} exact/>
)}
{publicRoutes.map(({path, Component}) =>
<Route key={path} path={path} component={Component} exact/>
)}
<Navigate to={SHOP_ROUTE}/>
</Routes>
);
});
export default AppRouter;
специально для
Aetae!!!
[Navigate] не является компонентом <Route>. Все дочерние компоненты <Routes> должны быть <Route> или <React.Фрагмент>