You need to add react as a JS dependency. Click on “Settings” at the top of your pen, then “Javascript” in the pop-up. Under “javascript preprocessor”, select Babel, and under “add external scripts/pens”, type “react”. Select both react and react-dom. You should now be ready to use React.
Dan Abramov writes it as: “It’s like watering the “dry” HTML with the “water” of interactivity and event handlers.”
The server sends the client HTML along with a link to the JS to download. The JS gets downloaded and then “hydrates” the page taking it from a plain page to one with interactivity meaning adding handlers to buttons, events to elements on the page like onClick and so forth.
Example: When you visit a Next.js site, the server sends static HTML to the browser
<!-- Server-side rendered (SSR) HTML --><div id="root"> <button>Count: 0</button></div>
After the page loads, React runs on the client, taking the static HTML and “hydrating” it (attaches event handlers, connects state, etc.)