simon360 / react-from-markup

Declare your React components with static HTML
MIT License
18 stars 4 forks source link

Access to rehydrateChildren from outside rehydrators #5

Closed simon360 closed 6 years ago

simon360 commented 6 years ago

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.

simon360 commented 6 years ago

Resolved by #6