Skip to content

Instantly share code, notes, and snippets.

@Kazunari-h
Created November 15, 2019 03:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Kazunari-h/3f1b52db8672a9e32ed289d7a50d6a3f to your computer and use it in GitHub Desktop.
Save Kazunari-h/3f1b52db8672a9e32ed289d7a50d6a3f to your computer and use it in GitHub Desktop.
'use strict';
// エレメントの作成
const e = React.createElement;
class LikeButton extends React.Component {
constructor(props) {
super(props);
this.state = {
liked: false,
count: 0
};
}
render() {
return e(
'button', {
onClick: () => this.setState({
liked: true,
count: this.state.count + 1
})
},
`いいね ${this.state.count}`
);
}
}
const domContainer = document.querySelector('#like_button_container');
ReactDOM.render(e(LikeButton), domContainer);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment