From the course: React: Advanced Code Challenges

Unlock this course with a free trial

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

Lifting up the state with context API: How?

Lifting up the state with context API: How? - React.js Tutorial

From the course: React: Advanced Code Challenges

Lifting up the state with context API: How?

- [Instructor] Now we see how to use useContext, which is a React Hook that lets create and share global states across the application in the application tree. This will allow components in the application tree to subscribe to state changes via the context, via the context objects. And for the syntax, so this is how it is, but for now, so let's look at the example that we want to improve and optimize. So here it is. So this is a dashboard example with multiple components, multiple memoized components. So this is one first good points. However, you're going to see that when we go to the main app components, that we have lots of states. So this is starting to become a complex logic and this is making the application. So as the app is growing, this is make... Rephrase. As the application grows, this is making the applications difficult to maintain, update, but also to optimize. So in order to fix it, we would like to actually centralize state management using context. So let's run the…

Contents