Skip to content

Instantly share code, notes, and snippets.

@tigerraj32
Created June 20, 2016 06:45
Show Gist options
  • Save tigerraj32/384236952f004fd969e2b46e5ddc2e74 to your computer and use it in GitHub Desktop.
Save tigerraj32/384236952f004fd969e2b46e5ddc2e74 to your computer and use it in GitHub Desktop.
var ComponentWithDefaultProps = React.createClass({
getDefaultProps: function() {
return {
value: 'default value'
};
}
});
------------------ or the other way ----------------------
ComponentWithDefaultProps. defaultProps = {
value:'default value',
}
class ComponentWithDefaultProps extends Component {
render(){
return(
<h1>{this.props.val}</h1>
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment