I'm still learning React and can't grasp the importance of
When designing interfaces, break down the common design elements
(buttons, form fields, layout components, etc.) into reusable
components with well-defined interfaces. That way, the next time you
need to build some UI, you can write much less code. This means faster
development time, fewer bugs, and fewer bytes down the wire.
React revolves around the concept of components. A whole webpage should be broken down into components and each components will interact with each other through
So, these are all the advantages of using
PropTypes is not compulsory.
[EDIT] Answers for the questions in order
props, which is extra code, you don't need to do it by yourself. Validations will be taken care by
Parentcomponent can be a child of another
Parentwhich can be a child of another. So, call it as
Rootcomponent which will be at the top of the UI tree. With this definition, you can say,
PropTypeis only applicable to
stateis with in a component's scope. But,
propsare passed from a component to another. So, it doesn't make sense to validate
stateof a component as it is not shared across components. Even if it is shared, that can be only done through
Hope it helps...