Browse Source

Interactivity and Dynamic UIs Docs page updated with ES6 Example (#6832)

* Interactivity and Dynamic UIs Pages ES6 Example

* Change bind handler
main
Vedat Mahir YILMAZ 9 years ago
committed by Jim
parent
commit
507f5935e6
  1. 26
      docs/03-interactivity-and-dynamic-uis.md

26
docs/03-interactivity-and-dynamic-uis.md

@ -11,22 +11,26 @@ You've already [learned how to display data](/react/docs/displaying-data.html) w
## A Simple Example ## A Simple Example
```javascript ```javascript
var LikeButton = React.createClass({ class LikeButton extends React.Component {
getInitialState: function() { constructor() {
return {liked: false}; super();
}, this.state = {
handleClick: function(event) { liked: false
}
this.handleClick = this.handleClick.bind(this);
}
handleClick() {
this.setState({liked: !this.state.liked}); this.setState({liked: !this.state.liked});
}, }
render: function() { render() {
var text = this.state.liked ? 'like' : 'haven\'t liked'; const text = this.state.liked ? 'like' : 'haven\'t liked';
return ( return (
<p onClick={this.handleClick}> <div onClick={this.handleClick}>
You {text} this. Click to toggle. You {text} this. Click to toggle.
</p> </div>
); );
} }
}); }
ReactDOM.render( ReactDOM.render(
<LikeButton />, <LikeButton />,

Loading…
Cancel
Save