August 2017
Beginner
374 pages
10h 41m
English
We still need to handle redirect components on the server side. In the client, the browser history changes state, and we get a new screen. On the server, we pass a context property to the StaticRouter component. If context.url exists, we know that the app has redirected, so we send a redirect response.
We are now going to adjust the code in server/render.js:
return initStore(store) .then(() => { let context = {} const markup = renderToString(
<StaticRouter location={isIndexPage ? '/' : req.url} context={context}>
Read now
Unlock full access