What is the difference between Component.defaultProps and this.state?

Welcome to the Get Help category!

Hello. I am new to React, but I don’t understand, for the moment, the differences between the Component.defaultProps and this.state properties of a component.

I am talking about this exercise.

In the last lesson where I learned about this.props, they introduced the .defaultProps, which is used to store some information if none is provided, when the component should be rendered.

But now you can do the same thing with this.state, which stores info in the Component class instance.

Is there any reason to use one property to the detriment of the other?

This is for pass information to one component to another component.