Skip to content

Instantly share code, notes, and snippets.

@tuxsudo
Created October 17, 2016 16:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tuxsudo/91d5ec605e50532f9830e09e6cd3a147 to your computer and use it in GitHub Desktop.
Save tuxsudo/91d5ec605e50532f9830e09e6cd3a147 to your computer and use it in GitHub Desktop.
import {Component} from 'react';
export default class extends Component {
state = {
open: false
};
toggle = () => {
this.setState(({open}) => ({open: !open}))
};
render() {
const {open} = this.state;
return (
<div>
<button onClick={this.toggle}>
Toggle
</button>
{open && (
<div>I am open</div>
)}
</div>
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment