How to properly implement PrivateRoute ???

Next question is PrivateRoute which checks in store redux are there any selegiline user in the system, I fetch user's Tokelau with local storage, and default it to null and then fetch if it is successful, the user appears in the system. The problem is that during the fetch the user PrivateRoute already redirect the user as metalogenia. To me it to solve, like asynchronously to check the user specila already and if not then redirected, but my knowledge is insufficient to solve it maybe someone of you already faced something similar (cookies not accepted).
March 23rd 20 at 19:03
1 answer
March 23rd 20 at 19:05
For example:
const PrivateRoute = ({ component: Component, render, isSignedIn, }) => (
 render={props => {
 if (!isSignedIn) return (
 pathname: '/login',
 state: { referrer: props.history.location.pathname },

 if (render) return render({ ...props });

 return <Component {...props} />;

const mapStateToProps = (state) => ({
 isSignedIn: isSignedInSelector(state),

export default connect(mapStateToProps)(PrivateRoute);

the referrer is passed here to return to the landing page after login.
Anton Spirin and that's no costil?? - Greta_Cormi commented on March 23rd 20 at 19:08
@Greta_Cormi, why? - Brooks commented on March 23rd 20 at 19:11
@Brooks, OK thanks - Greta_Cormi commented on March 23rd 20 at 19:14

Find more questions by tags React