Skip to content

Instantly share code, notes, and snippets.

@ryanflorence
Created October 4, 2019 16:29
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 ryanflorence/9a5bd177832588bbb94f8541cf02b9a4 to your computer and use it in GitHub Desktop.
Save ryanflorence/9a5bd177832588bbb94f8541cf02b9a4 to your computer and use it in GitHub Desktop.
// #1
// can pass by name
<Button children={el2} />
const el = React.createElement(Button, { children: el2 })
// or by position
<Button>{el2}</Button>
const el = React.createElement(Button, null, el2)
// React theoretically turns it into this once you're in the component:
const el = React.createElement(Button, { children: el2 })
// #2 it flattens multiple children into an array
<Button>
<span/>
{stuff.map(() => <span/>)}
<span/>
</Button>
const el = React.createElement(Button, null, el2, [el3, el4], el5)
const el = React.createElement(Button, { children: [el2, el3, el4, el5] })
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment