Last active
December 1, 2016 15:13
-
-
Save mattmassicotte/23aea0a4c6aa6f9c0324a645f1cf97ec to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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