Skip to content

Instantly share code, notes, and snippets.

@NicholasKuchiniski
Last active March 5, 2018 00:47
Show Gist options
  • Save NicholasKuchiniski/70efd774d45091983b53c06b8c098b98 to your computer and use it in GitHub Desktop.
Save NicholasKuchiniski/70efd774d45091983b53c06b8c098b98 to your computer and use it in GitHub Desktop.
Mostrando e escondendo componentes com react.
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