DEV Community

baloukaulrich6
baloukaulrich6

Posted on

React private route

I can't create a protected route in react v6 even when the function is well declared. even being disconnected I can access the main page but error is.

0

import React from 'react';
import { Outlet, Navigate } from 'react-router-dom';

const PrivateRoute = ({component, token, children}) => {
if(!token){
return ;
} else {
return ;
};

};

export default PrivateRout;

//but as soon as I change position they differ return an error is created and the browser bugs

Top comments (0)