Skip to content

Instantly share code, notes, and snippets.

@StillLearnin
Created July 15, 2016 19:23
Show Gist options
  • Save StillLearnin/893a96587ef7c11ed72faceb01077096 to your computer and use it in GitHub Desktop.
Save StillLearnin/893a96587ef7c11ed72faceb01077096 to your computer and use it in GitHub Desktop.
React Component as ES6 class with state.
import React from 'react';
import bindAll from 'lodash/bindAll';
class Report extends React.Component {
constructor() {
super();
this.state = {};
bindAll(this, 'click');
}
render() {
if (!this.state.open)
return null;
return <div>
{this.props.children}
</div>
}
click() {
alert('Ha!')
}
}
export default Report;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment