react.js-08-state

前端之家收集整理的这篇文章主要介绍了react.js-08-state前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
@H_502_1@









var LikeButton = React.createClass({
getInitialState: function() {
return {liked: false};
},
handleClick: function(event) {
this.setState({liked: !this.state.liked});
},
render: function() {
var text = this.state.liked ? ‘like’ : ‘haven\’t liked’;
return (
@H_502_1@
You {text} this. Click to toggle.


);
}
}); @H_502_1@ReactDOM.render(,document.getElementById(‘example’) );

猜你在找的React相关文章