Skip to content

Instantly share code, notes, and snippets.

@ryanflorence
Last active April 7, 2017 22:43
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 4 You must be signed in to fork a gist
  • Save ryanflorence/5acb8fe383957d317951ad3406e0eb6e to your computer and use it in GitHub Desktop.
Save ryanflorence/5acb8fe383957d317951ad3406e0eb6e to your computer and use it in GitHub Desktop.
// prop callback
class Compoennt {
render() {
return (
<div>
<Thing onChange={(val) => {
this.setState({ val1: val })
}}/>
<Thing onChange={(val) => {
this.setState({ val2: val })
}}/>
<div>{this.state.val1 + this.state.val2}</div>
</div>
)
}
}
React.cloneElement(el, { val })
// context
<Thing>
<Child/>
</Thing>
// render callback
<Thing>
{(val1) => (
<Thing>
{(val2) => (
val1 + val2
)}
</Thing>
)}
</Thing>
// higher order component
withStuff(Thing)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment