文章加密

;

2020年2月27日 星期四

React router 4 “NOT FOUND” when I type in the URL in browser

https://stackoverflow.com/questions/44986152/react-router-4-not-found-when-i-type-in-the-url-in-browser

Isomorphic

What if we use Node JS as our server so we can run the same JS code on both ends? Now, we have all our routes defined in a single react-router config and we don't need to duplicate our rendering code. This is 'the holy grail' so to speak. The server sends the exact same markup as we would end up with if the page transition had happened on the client. This solution is optimal in terms of SEO.
Downsides:
  • Server must (be able to) run JS. I've experimented with Java i.c.w. Nashorn but it's not working for me. In practice it mostly means you must use a Node JS based server.
  • Many tricky environmental issues (using window on server-side etc)
  • Steep learning curve

沒有留言:

張貼留言