Skip to content

Instantly share code, notes, and snippets.

@cheton
Created May 19, 2017 06:02
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 cheton/cf244310724a4f590d6e870bcef0c8e8 to your computer and use it in GitHub Desktop.
Save cheton/cf244310724a4f590d6e870bcef0c8e8 to your computer and use it in GitHub Desktop.
xxxx
<Widget widgetId="threats" />
// ES7 class properties
class Widget extends React.Component {
state = this.getInitialState(); // ?
getInitialState() {
return {
widgetId: this.props.widgetId
};
}
}
// ES6 class constructor
class Widget extends React.Component {
constructor() {
super();
this.state = this.getInitialState(); // ?
}
getInitialState() {
return {
widgetId: this.props.widgetId
};
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment