score:2

Actually, it is ok to use this type of private route in react, but you should check two moments:

  1. I should check, that you do not have exact attribute, so all your routes like /dashboard/panel1, /dashboard/panel2 will be private to

    auth.isAuthenticated} path="/dashboard" component={Dashboard} />

  2. You will have some problem with connect. There is a simple fix for that:

    export default connect(mapStateToProps, null, null, { pure: false, })(PrivateRoute);

more information here: React router private routes / redirect not working


Related Query

More Query from same tag