react.js-08-state

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











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 (


You {text} this. Click to toggle.


);
}
});

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

原文链接:/react/307074.html

猜你在找的React相关文章