Skip to content

Instantly share code, notes, and snippets.

@hellobrian
Forked from ryanflorence/foo.js
Created April 7, 2017 18:45
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 hellobrian/e4ef3dd535b984eaca7e393d0fec55cd to your computer and use it in GitHub Desktop.
Save hellobrian/e4ef3dd535b984eaca7e393d0fec55cd 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