Skip to content

Instantly share code, notes, and snippets.

@jmlavoier
Created September 29, 2017 01:41
Show Gist options
  • Save jmlavoier/9efdd3f2e7b2d3087ca36e4058935ad7 to your computer and use it in GitHub Desktop.
Save jmlavoier/9efdd3f2e7b2d3087ca36e4058935ad7 to your computer and use it in GitHub Desktop.
const Button = ({ description, onClick }) => {
return (
<button onClick={onClick}>{description}</button>
);
}
class App extends React.Component {
constructor() {
super();
this.state = {
active: true,
}
}
onClick(event) {
const { active } = this.state;
this.setState({
active: !active,
});
}
render() {
const { active } = this.state;
return (
<div>
<Button
description={active ? 'Ativado' : 'Desativado'}
onClick={this.onClick.bind(this)}
/>
</div>
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment