Skip to content

Instantly share code, notes, and snippets.

@gaearon
Last active November 19, 2020 06:02
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save gaearon/c8e112dc74ac44aac4f673f2c39d19d1 to your computer and use it in GitHub Desktop.
Save gaearon/c8e112dc74ac44aac4f673f2c39d19d1 to your computer and use it in GitHub Desktop.
JSX version of LikeButton
'use strict';
class LikeButton extends React.Component {
constructor(props) {
super(props);
this.state = { liked: false };
}
render() {
if (this.state.liked) {
return 'You liked this.';
}
return (
<button onClick={() => this.setState({ liked: true }) }>
Like
</button>
);
}
}
let domContainer = document.querySelector('#like_button_container');
ReactDOM.render(<LikeButton />, domContainer);
@PhuruShekar
Copy link

What changes would we have to make to the index.html file and the buttons we are making to use JSX?

@tamlylyi
Copy link

  • [ ]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment