hydrateRoot
Check out the official React docs!
For more detailed information about React concepts and APIs, please refer to the official documentation for hydrateRoot.
ReactDOM.hydrateRoot is used to hydrate server-rendered HTML with React, attaching event handlers and making the UI interactive. This is essential for server-side rendering (SSR) setups.
module Example.HydrateRoot
open Feliz
open Fable.Core.JsInterop
// This example assumes you have server-rendered HTML with id "root" in your HTML
let root =
ReactDOM.hydrateRoot (Browser.Dom.document.getElementById ("root"), Example.UseId.UseId())
hydrateRoot accepts the same RootOptions as createRoot as a third argument. If you set identifierPrefix, it must match the prefix used on the server. Hydration mismatches that React can recover from are reported to onRecoverableError.
ReactDOM.hydrateRoot (
document.getElementById "root",
App(),
RootOptions(onRecoverableError = fun error _ -> console.warn ("Hydration issue:", error.Message))
)