Skip to content

Instantly share code, notes, and snippets.

@gaearon
Last active July 31, 2022 17:22
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gaearon/0b180827c190fe4fd98b4c7f570ea4a8 to your computer and use it in GitHub Desktop.
Save gaearon/0b180827c190fe4fd98b4c7f570ea4a8 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 };
}
render() {
if (this.state.liked) {
return 'You liked this.';
}
return e(
'button',
{ onClick: () => this.setState({ liked: true }) },
'Like'
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment