I have the following in my react app:
<PrivateRoute
path="/profile"
component={ Profile }
authenticated={ this.state.authenticated }
/>
<PrivateRoute/> is basically just the below:
const PrivateRoute = ({ component : Component , authenticated : auth , ...rest }) => {
return (
<Route {...rest} render={ (props) => {
return (
auth ? <Component {...props} />
: <Redirect
to={{
pathname : '/login',
state : {
from : props.location
}
}} />
)
} } />
)
}
As you can see in the above code there is a auth variable , how do i send this variable to now i would like to send this variable alog with the <Redirect /> which basically loads the <Login /> component , but how exactly do i send the auth variable alog with the Redirect component ?