Last active
March 5, 2018 00:47
-
-
Save NicholasKuchiniski/70efd774d45091983b53c06b8c098b98 to your computer and use it in GitHub Desktop.
Mostrando e escondendo componentes com react.
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
import React, { Component } from 'react'; | |
class JQueryToReact extends Component { | |
constructor(props) { | |
super(props); | |
this.state = { | |
isShow: false | |
} | |
} | |
toggle_menu = () => { | |
this.setState({ | |
isShow: !this.state.isShow | |
}); | |
} | |
render() { | |
return ( | |
<div> | |
{ | |
this.state.isShow ? <div>Está aberto</div> : <div>Está fechado</div> | |
} | |
<p /> | |
<button onClick={this.toggle_menu}>{this.state.isShow ? "Fechar" : "Abrir"}</button> | |
</div> | |
); | |
} | |
} | |
export default JQueryToReact; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment