Use Context to Manage Current User State - Introduction to React #8

preview_player
Показать описание
The React Context API allows passing data through the component tree without passing it as a prop at every level. It’s frequently used for global state like the current logged in user, themes, and other application-wide preferences. In this video I’ll focus on one of the most common use cases for context – storing information about the current user.

Contents:
0:00 Introduction
0:30 Introducing the Example App
0:50 The Component Tree
1:04 The Problem: Prop Drilling
1:20 The Solution: Context
1:33 Creating a Context
1:49 Setting up the Context Provider
2:23 Using the Context as Consumer
3:02 Passing State with Context
4:15 Abstracting the Context State and Provider
4:45 Conclusion

#react #course
Рекомендации по теме
Комментарии
Автор

Good video but the user data is not persisted if the page refreshes. Any solution?

feyselahmed
Автор

Amazing video, you explained it better than the docs did for me haha

LBPFrost
Автор

Thanks, how can you keep the state after a page refresh though, user gets lost?

shaunsorour
Автор

Wow... Best explanation I have seen for context, straightforward and insightful, thank you...

Can you do one with useReducer?

oseniadedoyin
Автор

Nice explanation, can you provide me the code project for this example i am new in react js

GulshanAli-cijx