I want to be able to perform:
router.push('/compose')
And if not logged user will be redirected to the login page and from there to /compose. I'll be happy to learn a generic React solution or a specific Ant Design Pro solution. I know that And Design Pro have AuthorizedRoute but I don't know if it can allow this.
I'm using react-router 4.3.1 and antd 3.23.6.
Thanks
EDIT:
It probably needs to be something like @tyler-mcginnin answer:
function PrivateRoute ({component: Component, authed, ...rest}) {
return (
<Route
{...rest}
render={(props) => authed === true
? <Component {...props} />
: <Redirect to={{pathname: '/login', state: {from: props.location}}} />}
/>
)
}