Why are ParentComponent.childContextTypes and ChildComponent.contextTypes needed?
1 answer
The parent component passes the context to this subtree. Therefore, we will indicate which type of your context can be used using the childContextTypes method.
The child component receives context from its parent. In your application, chances are many parent components pass the context as the same names. Thus, you define this type to identify these contexts.
In React JS, the Context API is one of the powerful APIs. So when you need this time, use Context.
0
source to share