Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Link object
- const wholeNbr = Yup.number().integer().positive()
- const MyLocation = new Location('/doc/:id', {id : wholeNbr.required()})
- //Unprotected route - Working code:
- { MyLocation.toRoute({ component: MyComponent, invalid: NotFoundPage }, true) }
- //Protected route - Not working:
- const privateLocation = (isAuthenticated, Component) => (
- isAuthenticated ?
- (
- <Component />
- ):(
- <Redirect to="/" /> //redirect to login page
- )
- )
- ...
- <Router history={history}>
- ...
- <Switch>
- ...
- { CategoryLocation.toRoute({ render: privateLocation(isAuthenticated, MyComponent), invalid: NotFoundPage }, true) }
- ...
- </Switch>
- </Router>
Add Comment
Please, Sign In to add comment