Optimizing Performance of React Context

  Рет қаралды 4,154

Software Developer Diaries

Software Developer Diaries

Жыл бұрын

In this React Context tutorial, we're gonna try to optimize our Context and avoid rerendering the components on every Context value update.
Consider supporting the channel by clicking the "Thanks" button ❤️
🙌 Become my Patreon and get exclusive perks: / softdevdiaries
💼 Follow me on LinkedIn and drop me a message if you'd like: / gusgadirov
💻 Also, let's connect on GitHub: github.com/gusgad
📚 Resources:
Code: github.com/gusgad/youtube-tut...
Official docs on Context optimization in React: react.dev/reference/react/use...
Cleaner React Contexts: mirone.me/performance-optimiz...
And don't forget to subscribe for more videos like this 😊
#react

Пікірлер: 19
@hamidhamri5384
@hamidhamri5384 Жыл бұрын
No way a channel like this has only 4k, keep up my man, I see you in 100k soon ❤
@SoftwareDeveloperDiaries
@SoftwareDeveloperDiaries Жыл бұрын
Appreciate it, my friend!
@nazmussakib5799
@nazmussakib5799 Ай бұрын
Thanks a lot for sharing
@DiogoLScarmagnani
@DiogoLScarmagnani Ай бұрын
Then it's very useful if we use useCallback for functions inside my provider and also useMemo for the provided values?
@numericalwallah9174
@numericalwallah9174 9 ай бұрын
What if its object i mean when i use usereducer and state is in object at i want to pass state directly os there any good way
@aram8639
@aram8639 Жыл бұрын
👍🏻 i like it
@SoftwareDeveloperDiaries
@SoftwareDeveloperDiaries Жыл бұрын
Thank you 😊
@code_react
@code_react Жыл бұрын
All the devs who works in my team. I ask them to divide the component into very small chunks.
@GrowthBhavsec
@GrowthBhavsec Жыл бұрын
Sir, i believe your LinkedIn link doesn't work anymore so could you please update me with that, Thank you
@juliansyah4byte57
@juliansyah4byte57 Жыл бұрын
like performance video
@SoftwareDeveloperDiaries
@SoftwareDeveloperDiaries Жыл бұрын
Will do more of these 👍
@jonathangamble
@jonathangamble Жыл бұрын
Why not just import signals from preact… obviously it would be better if that were built in.
@SoftwareDeveloperDiaries
@SoftwareDeveloperDiaries Жыл бұрын
Exactly. This time with the vanilla React tho :)
@nataneldemissew3426
@nataneldemissew3426 6 ай бұрын
the memo on children is unnecessary. ur right that useMemo on the value passed to the context is one issue bu another issue is that u have a state in the app that updates when u click update session, therefore rerendering all components displayed there. if u remove the context all together, u will still see the children rerendering even if they dont have memo. In this scenario, u shouldnt have a state in the app that is passed to the parent, the session id shouldnt be in the parent to avoid rerendering mistake #1 if u do that, u shouldnt need to memoize the children. I think..
@nataneldemissew3426
@nataneldemissew3426 6 ай бұрын
the session id should be in the parent, not in app. it triggers rerender of all components there.
@user-gn9ns7um2y
@user-gn9ns7um2y 3 ай бұрын
thanks🤏
@asiraky
@asiraky 9 ай бұрын
Your explanation is incorrect. It’s got nothing to do with the currentUserId state variable being different on each render. It because you are creating a new object out of it on each render.
@SoftwareDeveloperDiaries
@SoftwareDeveloperDiaries 9 ай бұрын
I meant exactly what you stated by “being different”, just the wrong wording :)
@asiraky
@asiraky 9 ай бұрын
If you’re goal is to teach people then your explanation should be accurate. Even the fact that you’re mentioning the state being reinstatiated at all is leading down the wrong path, as the state value of the useState in your case is a primitive, meaning it is referentially equal to the previous value. That might not seem like a big deal, but it is a huge deal as it means the state has literally nothing to do with the re-render but you made a point out of it as though it is. My suspicion is you don’t actually know what you’re on about. It wasn’t just bad wording.
Mastering React Context: Do you NEED a state manager?
37:26
Jack Herrington
Рет қаралды 96 М.
Чай будешь? #чайбудешь
00:14
ПАРОДИИ НА ИЗВЕСТНЫЕ ТРЕКИ
Рет қаралды 2,9 МЛН
Just try to use a cool gadget 😍
00:33
123 GO! SHORTS
Рет қаралды 50 МЛН
小女孩把路人当成离世的妈妈,太感人了.#short #angel #clown
00:53
Why Signals Are Better Than React Hooks
16:30
Web Dev Simplified
Рет қаралды 453 М.
Preventing React re-renders with composition
12:11
Developer Way
Рет қаралды 15 М.
The ultimate guide to web performance
6:43
Beyond Fireship
Рет қаралды 403 М.
8 React Js performance optimization techniques YOU HAVE TO KNOW!
11:23
Don't Use React Context!! Use This instead
13:34
CoderOne
Рет қаралды 26 М.
The correct way to optimise React
11:29
Cosden Solutions
Рет қаралды 29 М.
Making React Context FAST!
33:34
Jack Herrington
Рет қаралды 85 М.
Жёсткий тест чехла Spigen Classic C1
0:56
Romancev768
Рет қаралды 692 М.
сюрприз
1:00
Capex0
Рет қаралды 1,3 МЛН
5 НЕЛЕГАЛЬНЫХ гаджетов, за которые вас посадят
0:59
Кибер Андерсон
Рет қаралды 1,6 МЛН
Настоящий детектор , который нужен каждому!
0:16
Ender Пересказы
Рет қаралды 297 М.