Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var PeopleComponent = React.createClass({
- componentDidMount: function() {
- this.props.person.on("change", this._onChange);
- },
- getInitialState: function() {
- return {
- person: this.props.person,
- // trigger async call
- friends: this.props.person.getValue("friends")
- }
- },
- _onChange: function() {
- this.setState(this.getInitialState());
- },
- render: function() {
- <ul> {this.state.friends.map(function(friend) {
- return <li> { friend.name } </li>
- })} </ul>
- };
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement