Should I connect each component in my react app with context?

Suppose I have context setup and I have a component connected to context store. Now should I pass the context state through props to its child components or I should connect each child component to context? What architecture would scale well? Thanks

Connect each child to the context (as long as it actually needs it). The whole point of the context API is to avoid prop-drilling.

You’re probably better off using Redux and/or hooks rather than the context API though.

1 Like