Created
September 29, 2017 01:41
-
-
Save jmlavoier/9efdd3f2e7b2d3087ca36e4058935ad7 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
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