Improve developer experience for accessing context with a custom React hook

Share this video with your friends

Send Tweet

In this lesson, we create a custom hook that wraps the useContext hook and returns its value, as well as more useful error messaging if a context provider is missing. This simple addition brings very elegant ergonomics to access context from any component.