constructor(props){
super(props);
this.state = {
liked: false
};
this.onlick = this.onclick.bind(this);
}
onClick(e){
this.setState({
liked: true
})
}
render(){
return this.state.liked
? (
<section className="Post">
{this.props.children}
<span>Liked</span>
<button onClick="this.onClick">Like</button>
</section>
)
: (
<section className="Post">
{this.props.children}
<button onClick="this.onClick">Like</button>
</section>
)
}
}
давай простыню в гист
Обсуждают сегодня