Created
October 16, 2018 14:49
-
-
Save arackaf/db9af2cc42a795a672aa36eb93bbf3f3 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
class ContactDetails extends Component { | |
render() { | |
return ( | |
<SomeUtility> | |
{(primitiveValue, SomeComponent) => ( | |
//QUESTION: you see that <SomeComponent /> component that <SomeUtility /> is providing in the | |
//render props? Is it possible for some piece of state from <SomeUtility /> to be passed to | |
//<SomeComponent /> ***automatically*** whenever it's rendered? | |
//The best I can come up with is to *create* de novo <SomeComponent /> in <SomeUtility />'s constructor | |
//and then pass *that*, but it seems hacky. | |
//lots of cool additions to React lately - am I missing something? | |
<div> | |
{primitiveValue == 1 ? <SomeComponent val="a" /> : null} | |
{primitiveValue == 2 ? <SomeComponent val="b" /> : null} | |
{primitiveValue == 3 ? <SomeComponent val="c" /> : null} | |
</div> | |
)} | |
</SomeUtility> | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I usually use
React.createElement(SomeComponent, props)
which in your case would be parent's state that is passed as props. Don't know if this is what you need.I created similar example where I wanted to to use
uiWidget
as component and then pass all parent's state to them, also various callbacks.