Skip to content

Instantly share code, notes, and snippets.

@glenjamin
Last active January 13, 2017 21:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save glenjamin/debef88ce7d82cafac1759614d7711b5 to your computer and use it in GitHub Desktop.
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!
// 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