Skip to content

Instantly share code, notes, and snippets.

@mburakerman
Last active August 1, 2018 02:30
Show Gist options
  • Save mburakerman/42c73478fd9f133ab4c79b9956798dbe to your computer and use it in GitHub Desktop.
Save mburakerman/42c73478fd9f133ab4c79b9956798dbe to your computer and use it in GitHub Desktop.
defaultProps ES6 Syntax in React.js
// https://github.com/facebook/react/issues/3725
...
static get defaultProps() {
return {
count:1
}
}
....
// Usage
this.props.count
/* OTHER WAY */
....
static defaultProps = {
width:50,
height:50
};
constructor(props, defaultProps) {
super(props, defaultProps);
}
....
// Usage
this.props.width
this.props.height
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment