I have a simple application that shows a list of user comments. When the user clicks, the application should go to /users/<id>and show a new page with user data that will be requested from MongoDB. I find it difficult to understand where this logic should be.
I saw examples of using a jet router in a client, for example:
render((
<Router>
<Route path="/" component={App}>
<Route path="/user/:userId" component={User}/>
</Route>
</Router>
), document.body)
But also on the server side:
<Route name="root" path="/" handler={require('./handlers/Root')}>
And also using express routing:
app.get('/', function home (req, res, next) {
res.render('layout', {
reactHtml: React.renderToString(<App />)
});
});
app.get('/user', function home (req, res, next) {
res.render('layout', {
reactHtml: React.renderToString(<User />)
});
});
Which one is the way? What are the differences?
Yuval source
share