4 ms·
React is already championing this - React 16 has the new hydration function specially designed for exactly this kind of scenario. There is now complete and offi
by sudhirj 9y ago
React is already championing this - React 16 has the new hydration function specially designed for exactly this kind of scenario. There is now complete and official support for the following paradigm:
* Write your app as React views
* As much as possible, render either the app skeleton or the full view on server
* Serve rendered HTML with async/deferred JS tags https://reactjs.org/docs/react-dom-server.html https://reactjs.org/docs/react-dom-server.html
* Optionally hydrate the HTML with React whenever the JS is done loading. https://reactjs.org/docs/react-dom.html#hydrate https://reactjs.org/docs/react-dom.html#hydrate
* If the current page is a static page and doesn't need JS, don't even bother loading any JS. Just use https://reactjs.org/docs/react-dom-server.html#rendertostaticmarkup https://reactjs.org/docs/react-dom-server.html#rendertostati... to begin with.