Optimizing Performance of React Context

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

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.
A Beginner's Guide to Event-Driven Architecture
37:28
Software Developer Diaries
Рет қаралды 4,9 М.
Context API in react | get the concept
29:00
Hitesh Choudhary
Рет қаралды 42 М.
Climbing to 18M Subscribers 🎉
00:32
Matt Larose
Рет қаралды 31 МЛН
Which one is the best? #katebrush #shorts
00:12
Kate Brush
Рет қаралды 23 МЛН
Универ. 10 лет спустя - ВСЕ СЕРИИ ПОДРЯД
9:04:59
Комедии 2023
Рет қаралды 2,1 МЛН
Countries Treat the Heart of Palestine #countryballs
00:13
CountryZ
Рет қаралды 30 МЛН
Advanced Golang: Channels, Context and Interfaces Explained
22:17
Code With Ryan
Рет қаралды 109 М.
The correct way to optimise React
11:29
Cosden Solutions
Рет қаралды 29 М.
TypeScript Generics are EASY once you know this
22:21
ByteGrad
Рет қаралды 124 М.
All Rust features explained
21:30
Let's Get Rusty
Рет қаралды 285 М.
3 Ways to Make React App FASTER
14:43
Piyush Garg
Рет қаралды 30 М.
Object Oriented Programming is Good | Prime Reacts
31:30
ThePrimeTime
Рет қаралды 287 М.
Making React Context FAST!
33:34
Jack Herrington
Рет қаралды 85 М.
Rust Demystified 🪄 Simplifying The Toughest Parts
14:05
Code to the Moon
Рет қаралды 171 М.
How charged your battery?
0:14
V.A. show / Магика
Рет қаралды 6 МЛН
Неразрушаемый смартфон
1:00
Status
Рет қаралды 1,2 МЛН
После ввода кода - протирайте панель
0:18
МОЩНЕЕ ТВОЕГО ПК - iPad Pro M4 (feat. Brickspacer)
28:01
ЗЕ МАККЕРС
Рет қаралды 85 М.