Skip to content

Instantly share code, notes, and snippets.

Created March 13, 2016 06:00
Show Gist options
  • Save anonymous/bfbb97e30a784e7c91ee to your computer and use it in GitHub Desktop.
Save anonymous/bfbb97e30a784e7c91ee to your computer and use it in GitHub Desktop.
import React from 'react';
import { render } from 'react-dom';
class Page extends React.Component {
state = {
shouldShowBox: true
};
toggleBox = () => {
this.setState({
shouldShowBox: !this.state.shouldShowBox
});
};
render () {
return <div className="page">
{ this.state.shouldShowBox && <div className="box"/>}
<button
className="toggle-btn"
onClick={this.toggleBox}
>
toggle
</button>
</div>;
}
}
render(<Page/>, document.querySelector('#container'));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment