Created
March 26, 2015 19:27
-
-
Save tomatau/86c0f9d0ad844542b94c to your computer and use it in GitHub Desktop.
Reversing Data Flow
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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