Skip to content

Instantly share code, notes, and snippets.

@mattmassicotte
Last active December 1, 2016 15:13
Show Gist options
  • Save mattmassicotte/23aea0a4c6aa6f9c0324a645f1cf97ec to your computer and use it in GitHub Desktop.
Save mattmassicotte/23aea0a4c6aa6f9c0324a645f1cf97ec to your computer and use it in GitHub Desktop.
return (
<MultiChildComponent>
<ChildNode key="child1">
<span>Yo</span>
</ChildNode>
<ChildNode key="child2">
<span>Dawg</span>
</ChildNode>
</MultiChildComponent>
);
class MultiChildComponent extends React.Component {
getNamedChild(key) {
// hunt through this.props.children, looking for ChildNodes, and then matching by key
// ...
}
render() {
return (
<div>
<div>
{this.getNamedChild("child1")}
</div>
<div>
{this.getNamedChild("child2")}
</div>
</div>
);
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment