From the course: React: State Management (2019)

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Defining Context

Defining Context - React.js Tutorial

From the course: React: State Management (2019)

Start my 1-month free trial

Defining Context

- [Instructor] React's context API is a great way to manage state without introducing a third-party library like Mobx or Redux. Before context, React developers didn't have an easy way to manage state in mid-sized applications. The options were to either use prop drilling, which introduces unnecessary confusion or bring in Redux, which introduces unnecessary complexity. Context exists for small to mid-sized applications that need some way to know about data without prop drilling. If you're wondering what the threshold is where prop drilling becomes a problem, my personal heuristic is asking myself if I'm annoyed passing down props from component to component, which typically happens if I'm prop drilling through three components. So let's take a look and see what exactly is context? It's a way to broadcast data to other components. React uses the terms providers and consumers for the two types of components involved in context. There's a component which provides state and components…

Contents