Created
November 15, 2019 03:45
-
-
Save Kazunari-h/3f1b52db8672a9e32ed289d7a50d6a3f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'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