Setting Default Component Props
Default props can be set when a component is being defined by using the getDefaultProps configuration value.
In the code example below the Badge component has a default value for the name prop.
Default props will be set on this.props if no prop is sent into the component. You can verify this by the fact that the Badge component instance with no name prop uses the default name 'John Doe'.
Notes
- The
getDefaultPropsis invoked once and cached when the component is created. - The
getDefaultPropsis run before any instances are created thus usingthis.propsinside of thegetDefaultPropswill not work. - Any objects returned by
getDefaultProps()will be shared across instances, not copied.

