Last active
January 13, 2017 21:13
-
-
Save glenjamin/debef88ce7d82cafac1759614d7711b5 to your computer and use it in GitHub Desktop.
Which of these do you prefer for a component-wrapping API? please comment below!
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
// The hypothetical <Routing /> component would pass extra props to <App /> to say which route is active | |
// 1. Wrapped component accepts component class and passes on props plus extras | |
<Routing | |
rootComponent={App} | |
propForApp="abc" | |
propForApp2="def" | |
/> | |
// 2. Wrapped component takes children and uses cloneElement to pass extra props | |
<Routing> | |
<App propForApp="abc" propForApp2="def" /> | |
</Routing> | |
// 3. Wrapped component takes component class and extra props as an object | |
<Routing | |
rootComponent={App} | |
rootProps={{ | |
propForApp: "abc", | |
propForApp2: "def" | |
}} | |
/> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment