Created
November 21, 2017 20:41
-
-
Save DiegoPinho/9d32958089122afb8bdc0fc60700897e to your computer and use it in GitHub Desktop.
This file contains 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
class App extends React.Component { | |
constructor(props) { | |
super(props); | |
this.state = {showModal: false}; | |
this.mostraModal = this.mostraModal.bind(this); | |
this.escondeModal = this.escondeModal.bind(this); | |
} | |
mostraModal() { | |
this.setState({showModal: true}); | |
} | |
escondeModal() { | |
this.setState({showModal: false}); | |
} | |
render() { | |
const modal = this.state.showModal ? ( | |
<Modal> | |
<div className="modal"> | |
<div>Olá, eu sou um modal!</div> | |
<button onClick={this.escondeModal}>Hide modal</button> | |
</div> | |
</Modal> | |
) : null; | |
return ( | |
<div> | |
<button onClick={this.mostraModal}>Show modal</button> | |
{modal} | |
</div> | |
); | |
} | |
} | |
ReactDOM.render(<App />, document.getElementById('root')); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment