you can create your custom component for authorization and used like this
<PrivateRoute
path="/login"
component={Login}
if={!isLogged()}
redirect="/"
/>
see this component take if as props, and here you can put your condition.
and this is how your custom component look like
import React from 'react'
import { Redirect, Route } from 'react-router-dom'
const PrivateRoute = props => {
const condition = props.if
const Component = props.component
const redirect = props.redirect
return (
condition
? <Route path={props.path} component={Component} />
: <Redirect to={redirect} />
)
}
export default PrivateRoute