import React, { useContext } from 'react';
import {Routes, Route, Navigate} from 'react-router-dom'
import { authRoutes, publicRoutes } from '../routes.js';
import { SHOP_ROUTE } from '../utils/consts.js';
import {Context} from "../index.js";
const AppRouter = () => {
const {user} = useContext(Context);
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
[Navigate] is not a <Route> component. All component children of <Routes> must be a <Route> or <React.Fragment>