I'm trying to create a protected route that will redirect to /login
when user is not authorized using Found Router for Relay Modern based off the example given by React Router:
const PrivateRoute = ({ component: Component, ...rest }) => {
return (<Route {...rest} render={props => {
if (!props) return
if (Component && props && props.viewer) {
return (<Component {...props} />)
} else {
throw new RedirectException('/login')
}
}}
/>)
}
I'm replacing the fakeAuth with real login logic, but the rest is the same. The Route just doesn't render.
Found Router seems to be light on examples around this specific problem. Any ideas?