In this post I want to explore the idea of using contexts in React to implement dependency injection (DI) in our application.
We’ll cover two things:
What contexts are in React and how they work
Why we care about DI and how we can implement them using contexts.
React and Contexts
Contexts were formalized in React 0.12, and are planned for React 1.0. They are a mechanism for a component to pass properties down to their descendent components. The difference between props and context is that context chains to descendents, whereas props do not.
Your new post is loading...