Should we always set defaultProps for every prop value?


#1

Question

In the context of this exercise, should we always set defaultProps for every prop value of the component?

Answer

You do not always have to set defaultProps for every single prop value of a component.

In some cases, it can be important to do so. defaultProps should be used for any props that are required for the component, such as an input value. Also, props that will cause errors if they are missing a value, or cause the display to appear unsatisfactorily should be given a default value so that the page can still run smoothly.


FAQ: this.props - defaultProps