Skip to content

Instantly share code, notes, and snippets.

@cheapsteak
Forked from anonymous/starting-simple.jsx
Created January 24, 2017 02:47
Show Gist options
  • Save cheapsteak/77b10892c4d10d6b9428fcd8aeff7993 to your computer and use it in GitHub Desktop.
Save cheapsteak/77b10892c4d10d6b9428fcd8aeff7993 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