Default component property values
React lets you define default values for properties in a very declarative way. The default value is used if the parent does not pass a property.
Default values are returned by a method getDefaultProps
, which is a member of the object passed to React.createClass
. Here is some sample code:
var ComponentWithDefaultProps = React.createClass({ getDefaultProps: function() { return { value: 'default value' }; } });