Dependency Injection with React Context
Dependency injection is a common software pattern, with clear benefits, including easier testing, and better reusability of code. While there are React dependency-injection libraries available, React doesn't provide a native implementation of this pattern. It does, however, provide useContext, which can be used to gain many of the benefits of dependency injection. Today, we're going to take a look at why you might want to use dependency injection, how you can go about doing it with useContext, and what the pros and cons are of this approach vs using a library.
Erin Zimmer
Erin is a Google developer expert, with over ten years experience in a variety of languages, from JavaScript to Model204 (no, nobody else has heard of it either). She is currently Senior Engineer at Atlassian. She is an active member of the Melbourne developer community, and has spoken at conferences around the world. If you see her at a conference, she'll probably have knitting needles in hand.