From the course: Build Modern Web Apps with React, Hooks, State Management, and APIs Using Vite or Next.js

Unlock this course with a free trial

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

Use cases: Summary

Use cases: Summary

Welcome back. Let's study our UseContextHook further. As you know that the main advantage of UseContextHook is that it avoids prop drilling problem. If we are not using the context, then we have to pass on the props throughout the component tree, which can be a very bad code and lagging application. From our app, to layout, to page, to component, the prop is still going to travel throughout. But if we have the context, we can access that datapiece from any depth inside our component with the help of useContext hook. It makes it easier to scale our large applications and not to bulk them or include problems like properly. Let's discuss some real use cases of use context and creating a context. The first one, which we already did a example of, is theme management. We can use it to maintain the authentication state of a user. If a user has logged in, then we need to keep the information on our front end as well. Like, what is the name of the user or if the user is an admin user or not…

Contents