Guest User

Untitled

a guest
Feb 16th, 2019
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.64 KB | None | 0 0
  1. //Link object
  2. const wholeNbr = Yup.number().integer().positive()
  3. const MyLocation = new Location('/doc/:id', {id : wholeNbr.required()})
  4.  
  5. //Unprotected route - Working code:
  6. { MyLocation.toRoute({ component: MyComponent, invalid: NotFoundPage }, true) }
  7.  
  8. //Protected route - Not working:
  9. const privateLocation = (isAuthenticated, Component) => (
  10. isAuthenticated ?
  11. (
  12. <Component />
  13. ):(
  14. <Redirect to="/" /> //redirect to login page
  15. )
  16. )
  17. ...
  18. <Router history={history}>
  19. ...
  20. <Switch>
  21. ...
  22. { CategoryLocation.toRoute({ render: privateLocation(isAuthenticated, MyComponent), invalid: NotFoundPage }, true) }
  23. ...
  24. </Switch>
  25. </Router>
Add Comment
Please, Sign In to add comment