Skip to content

Instantly share code, notes, and snippets.

@tomatau
Created March 26, 2015 19:27
Show Gist options
  • Save tomatau/86c0f9d0ad844542b94c to your computer and use it in GitHub Desktop.
Save tomatau/86c0f9d0ad844542b94c to your computer and use it in GitHub Desktop.
Reversing Data Flow
let ClickableList = React.createClass({
render(){
let { inputs, onClickItem } = this.props;
return (
<ul>
{inputs.map((input,i)=>
<li key={i} onClick={onClickItem.bind(null, input)}>
{input}
</li>
)}
</ul>
)
}
});
let MyClickableList = React.createClass({
render(){
return (
<ClickableList
inputs={["one", "two", "three", "four"]}
onClickItem={this.handleClickInput}
/>
)
},
handleClickInput(input, event){
console.log(input)
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment