Why? There are use cases for rehydration inside React components. This can be particularly useful when rendering fetched content. A React component may fetch() some HTML from a remote server, and want to render the response as children; those children may contain rehydratables. Since we're already in a React tree, a ReactDOM.render isn't desireable.
Proposal
rehydrateChildren is determined by react-from-markup, not dom-element-to-react; see here. The actual implementation is here.
The version that gets passed to rehydrators is simplified; it has the list of rehydrators and options baked in. react-from-dom could also export the complex version, which expects a node, a list of rehydrators, and an options object.
Why? There are use cases for rehydration inside React components. This can be particularly useful when rendering
fetch
ed content. A React component mayfetch()
some HTML from a remote server, and want to render the response as children; those children may contain rehydratables. Since we're already in a React tree, aReactDOM.render
isn't desireable.Proposal
rehydrateChildren
is determined byreact-from-markup
, notdom-element-to-react
; see here. The actual implementation is here.The version that gets passed to rehydrators is simplified; it has the list of rehydrators and options baked in.
react-from-dom
could also export the complex version, which expects anode
, a list of rehydrators, and an options object.