private route router code example
Example: private routes in react
import React from 'react'
import {Route, Redirect} from 'react-router-dom'
const PrivateRoute = ({
component: Component,
isAuthenticated,
userLevel,
...rest
}) => (
<Route {...rest} component={(props)=>
isAuthenticated ? (
<Component {...props} />
):(
<Redirect to="/login" />
)
} />
)
export default PrivateRoute