Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <Switch>
- <Router path="/users/:uid" component={Profile} />
- <Router path="*" component={NotFound} />
- </Switch>
- app.get('/users/:uid', (req, res) {
- if( // user exist) {
- res.json({user})
- }
- else res.status(404).json({ message: 'User not exist'})
- })
- class Profile extends Component {
- componentWillMount = () => {
- this.props.fetchUser(uid)
- }
- render(){
- if(!this.props.loading && this.props.user) return <NotFound />
- else return (...)
- }
- }
Add Comment
Please, Sign In to add comment