-
Notifications
You must be signed in to change notification settings - Fork 42
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Register children as props #48
Comments
FWIW, I tried to make a custom factory for doing this, but by the time the factory's |
Here is my custom factory that does this…it is a bit hacky because it relies on the
Example Usage…
|
Hey @timkelty, I just found a built-in way to do this, using the <div dangerouslySetInnerHTML={{__html: this.props.proxy.innerHTML}} /> That wouldn't do any of the child props stuff, but you could do that with something like htmr (which is what I am using) to convert the HTML string to React components. Then you wouldn't need the import React from 'react';
import convert from 'htmr';
const MyComponent = ({foo, proxy}) => (
<div>
<p>{foo}</p>
{convert(proxy.innerHTML)}
</div>
); <div data-component="MyComponent" data-props='{"foo": "bar"}'>
<div className="my-class">
<p>Some content…</p>
</div>
</div> Renders something like this: <div data-habitat="C1">
<div>
<p>bar</p>
<div class="my-class">
<p>Some content…</p>
</div>
</div>
</div> |
@iainsimmons oh nice!
Didn't realize that! |
I thought it would be neat if we were able to register children of the component root:
This could also be used as progressive enhancement, or a way inject SEO data.
The text was updated successfully, but these errors were encountered: