Skip to content

Instantly share code, notes, and snippets.

@codingnninja
Created September 5, 2018 07:15
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 codingnninja/1bde243523a75cfa4ae98fccfd952edc to your computer and use it in GitHub Desktop.
Save codingnninja/1bde243523a75cfa4ae98fccfd952edc to your computer and use it in GitHub Desktop.
'use strict';
const e = React.createElement;
class FollowButton extends React.Component {
constructor(props) {
super(props);
this.state = { follow: false };
}
render() {
if (this.state.follow) {
return 'You are following this.';
}
//create like button
return e(
'button',
{ onClick: () => this.setState({ follow: true }) },
'Follow'
);
}
}
//get DOM entry point with an Id called root
const domEntryPoint= document.getElementById('root');
ReactDOM.render(e(FollowButton), domEntryPoint);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment