From the course: React: State Management

Unlock the full course today

Join today to access over 25,200 courses taught by industry experts.

Getting started with the context API

Getting started with the context API - React.js Tutorial

From the course: React: State Management

Getting started with the context API

- [Instructor] In a typical React application, data is passed top-down, from parents to child, via the props. This needs to be done manually, from top to bottom, by going through every component's level, which can be very tedious and difficult to maintain. This works very well for small and basic applications. But imagine you have much bigger applications with multiple levels. It can become very challenging. And so the more complex is the application, the more complex is the communications between components and the more complex it is to share the state across the application. The solution is the Context API. That is a way to share values without having to explicitly and manually pass the data from the parents to the child components. So why use a context object and the Context API? First, it provides a way to manage the application state in a single, centralized location. And it helps to avoid the common pitfall of props…

Contents