Advanced Web Development With React by Mehul Mohan

Advanced Web Development With React by Mehul Mohan

Author:Mehul Mohan [Mohan, Mehul]
Language: eng
Format: epub
ISBN: 9789389423594
Publisher: BPB Publications
Published: 2020-08-15T00:00:00+00:00


ReactDOM.hydrate

Instead of making use of ReactDOM.render, we’re making use of ReactDOM.hydrate. ReactDOM.hydrate, as the name says, just hydrates the existing layout, it doesn’t create the layout and replaces it in DOM. ReactDOM.hydrate knows that the layout string is coming from the server, so it just needs to sync the client-side JS (i.e. events and listeners) with the coming server-side HTML code. Hence, we make use of the hydrate method.

One interesting thing here to note is that ReactDOM.hydrate expects the layout you provide on the frontend (in client.js) to be close to that coming from the backend (server.js), otherwise it’ll create problems for you.

Finally, let’s set up webpack for frontend so that we canmake use of the import/export syntax and actually use React on the frontend.

We already installed webpack earlier, so just go ahead and create a webpack.config.js file like this:



Download



Copyright Disclaimer:
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.