Advertisement
Guest User

Untitled

a guest
May 4th, 2015
236
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.57 KB | None | 0 0
  1. var PeopleComponent = React.createClass({
  2. componentDidMount: function() {
  3. this.props.person.on("change", this._onChange);
  4. },
  5. getInitialState: function() {
  6. return {
  7. person: this.props.person,
  8.  
  9. // trigger async call
  10. friends: this.props.person.getValue("friends")
  11. }
  12. },
  13. _onChange: function() {
  14. this.setState(this.getInitialState());
  15. },
  16. render: function() {
  17. <ul> {this.state.friends.map(function(friend) {
  18. return <li> { friend.name } </li>
  19. })} </ul>
  20. };
  21. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement