Guest User

Untitled

a guest
Oct 17th, 2018
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.50 KB | None | 0 0
  1. <Switch>
  2. <Router path="/users/:uid" component={Profile} />
  3. <Router path="*" component={NotFound} />
  4. </Switch>
  5.  
  6. app.get('/users/:uid', (req, res) {
  7. if( // user exist) {
  8. res.json({user})
  9. }
  10.  
  11. else res.status(404).json({ message: 'User not exist'})
  12. })
  13.  
  14. class Profile extends Component {
  15.  
  16. componentWillMount = () => {
  17. this.props.fetchUser(uid)
  18. }
  19.  
  20. render(){
  21.  
  22. if(!this.props.loading && this.props.user) return <NotFound />
  23. else return (...)
  24. }
  25. }
Add Comment
Please, Sign In to add comment