Optimizing Rendering Performance in React

  Рет қаралды 66,078

Software Developer Diaries

Software Developer Diaries

Жыл бұрын

We are going to use some performance optimization techniques to fix re-rendering issues in our React app that we discovered after performance profiling using React Developer Tools. React Hooks such as useCallback and memo play a big role here. Let's see how they can help here.
======⚡⚡⚡======
Get a 20% discount on Brilliant.org (to learn Science, Technology, Engineering, and Math): brilliant.sjv.io/kjVO2z
======⚡⚡⚡======
🙌 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:
React Docs on Optimizing Performance: reactjs.org/docs/optimizing-p...
And don't forget to subscribe for more videos like this 😊
#react #javascript

Пікірлер: 102
@SoftwareDeveloperDiaries
@SoftwareDeveloperDiaries Жыл бұрын
Obviously such optimizations are not necessary with a small number of re-rendered children as long as they are not too heavy. But at what point does memoizing become important? 100 items, 1.000 items or maybe 100.000 items? Share your thoughts here ✌
@kasemalolo5587
@kasemalolo5587 Жыл бұрын
I want to ask if I have a lot of element and put them in memo function Will it cause me memory problems?
@GuestUser-vf9qe
@GuestUser-vf9qe 6 ай бұрын
Try to have a large form of inputs. And control this form via Formik library for validation of user input. Probably (or even highly likely) you'll face some issues with unnecessary re-rendering...
@shy6489
@shy6489 10 ай бұрын
mind-blowing, that's what i was searching for a very long time 🔥🔥
@muhammadumar5385
@muhammadumar5385 Жыл бұрын
This helps get a deeper insight, very helpful. At least for a beginner like me. Keep up the good work.
@maximus4510
@maximus4510 Жыл бұрын
I like this channel it deserves more subscribers🔥 you're very calm and your explanation while coding is so clear and straight to the point. Thank you for your quality content!
@SoftwareDeveloperDiaries
@SoftwareDeveloperDiaries Жыл бұрын
I appreciate your feedback my friend!
@multiverse915
@multiverse915 20 күн бұрын
Bro explained useMemo and useCallback hook in a much easy manner 👏👏
@rohan7011
@rohan7011 Жыл бұрын
the best useCallback usage and example!
@JenJHayden
@JenJHayden 7 ай бұрын
This was a great video. I am brand now to full stack development. Days old. I looked up a video he mentioned to learn about profiling and performance to speed up a build. I looked up some stuff and I go here to your video. The problem for me is I think I am a little too new to full appreciate it yet. I took notes on everything you said and I have bookmarked this. Thank you.
@SoftwareDeveloperDiaries
@SoftwareDeveloperDiaries 7 ай бұрын
Happy to hear that! Good luck in your journey 😊
@AdamFiregate
@AdamFiregate 4 ай бұрын
Great summary and presentation! Thank you.
@UsmanTheDev
@UsmanTheDev Жыл бұрын
It was very helpful, thanks for your efforts
@tikamikas3245
@tikamikas3245 6 ай бұрын
Massive thank you!! You explained this perfectly and helped me solve an extremely annoying bug I’ve been dealing with 👏🏼
@SoftwareDeveloperDiaries
@SoftwareDeveloperDiaries 6 ай бұрын
Happy to hear that! 😊
@felixdziekan7335
@felixdziekan7335 Жыл бұрын
Thx for the info will try that later!
@persianman72
@persianman72 7 ай бұрын
You saved my time with this video, thank you!
@germanmartinezsolis9543
@germanmartinezsolis9543 Жыл бұрын
Thanks bro I'm gonna use this advices for my further project
@faridul.hassan
@faridul.hassan 11 ай бұрын
Thank you for this awesome tutorial.
@mrunalvaidya388
@mrunalvaidya388 Жыл бұрын
Watched your 10-15 videos(1st day), amazing Stuff and beautifully explained!!!!
@SoftwareDeveloperDiaries
@SoftwareDeveloperDiaries Жыл бұрын
Thans a lot! Glad you like them!
@costaszeimpekis994
@costaszeimpekis994 Жыл бұрын
Very good analysis, great work
@SoftwareDeveloperDiaries
@SoftwareDeveloperDiaries Жыл бұрын
Thanks mate :)
@rubylnic
@rubylnic 3 ай бұрын
thank you for the great example of real life usage of these hooks! It's so precious among other explanations
@SoftwareDeveloperDiaries
@SoftwareDeveloperDiaries 3 ай бұрын
Happy to hear that! ❤️
@stephenfoster6308
@stephenfoster6308 3 ай бұрын
Really useful video!
@mostafabrazi4228
@mostafabrazi4228 Жыл бұрын
Well explained, good job👍
@SoftwareDeveloperDiaries
@SoftwareDeveloperDiaries Жыл бұрын
Glad it was helpful!
@acearvingando6848
@acearvingando6848 Жыл бұрын
well explained 👍 appreciate your content
@SoftwareDeveloperDiaries
@SoftwareDeveloperDiaries Жыл бұрын
Thank you mate ✌
@ichigoplayss376
@ichigoplayss376 10 ай бұрын
Wow, Thanks a lot bro. Now I understand it
@kimberlyrojas3421
@kimberlyrojas3421 Жыл бұрын
Really helpful, thank you!
@SoftwareDeveloperDiaries
@SoftwareDeveloperDiaries Жыл бұрын
Glad to hear! 🙂
@VictorZamanian
@VictorZamanian 6 ай бұрын
But was the memo() of the child input components necessary after the useCallback() addition? Was the callback the only issue, or was memoization of the components themselves also necessary?
@archiee1337
@archiee1337 10 ай бұрын
Cool stuff, thanks
@jorgejorge8878
@jorgejorge8878 6 ай бұрын
Dude, more! First video I watched and I loved it
@SoftwareDeveloperDiaries
@SoftwareDeveloperDiaries 6 ай бұрын
Happy to hear mate! More to come :)
@easifier
@easifier 9 ай бұрын
thank you for this quite helpful info 👍🏻
@SoftwareDeveloperDiaries
@SoftwareDeveloperDiaries 9 ай бұрын
My pleasure 🤓
@kiadtisuk8857
@kiadtisuk8857 Жыл бұрын
That is helpful for my work, Thanks for this vdo
@SoftwareDeveloperDiaries
@SoftwareDeveloperDiaries Жыл бұрын
That's awesome, happy to hear!
@andregomes7232
@andregomes7232 Жыл бұрын
Amazing content! thanks
@SoftwareDeveloperDiaries
@SoftwareDeveloperDiaries Жыл бұрын
Thanks mate!
@bustopgamer5802
@bustopgamer5802 Жыл бұрын
Great job
@havefun5519
@havefun5519 11 ай бұрын
Thanks for the video.
@SoftwareDeveloperDiaries
@SoftwareDeveloperDiaries 11 ай бұрын
Sure, thanks for watching 🙂
@devcode9715
@devcode9715 Жыл бұрын
Great job 👏
@SoftwareDeveloperDiaries
@SoftwareDeveloperDiaries Жыл бұрын
Thank you! 😃
@davidcunha7615
@davidcunha7615 3 ай бұрын
Thanks :)
@friendsfair9283
@friendsfair9283 2 ай бұрын
It was a good video. If you create a playlists on performance optimization, that would be great❤
@SoftwareDeveloperDiaries
@SoftwareDeveloperDiaries 2 ай бұрын
I will consider it! Thank you 😊
@yaakovhassoun8965
@yaakovhassoun8965 3 ай бұрын
I've seen code like this in my codebase at work and didn't really get why it was necessary, this kinda makes a lot of sense
@ToastRusk
@ToastRusk 9 ай бұрын
This was soooo good.
@SoftwareDeveloperDiaries
@SoftwareDeveloperDiaries 9 ай бұрын
Yaay 🥳
@hillelspivakov3140
@hillelspivakov3140 Жыл бұрын
Hi, great video. What theme are you using for your vscode?
@SoftwareDeveloperDiaries
@SoftwareDeveloperDiaries Жыл бұрын
Thanks! It’s “Atom Dark One” :)
@zainkhas93
@zainkhas93 Жыл бұрын
Quality content!
@SoftwareDeveloperDiaries
@SoftwareDeveloperDiaries Жыл бұрын
Thanks mate!
@mohdsahil226
@mohdsahil226 Жыл бұрын
very well explained! Would you please explain virtual DOM and how it updates the RealDOM?
@SoftwareDeveloperDiaries
@SoftwareDeveloperDiaries Жыл бұрын
Hey mate! I put it on my list, but in the meantime I found this insightful article, maybe it could help you :) blog.logrocket.com/virtual-dom-react/
@user-ut4hj7kc1t
@user-ut4hj7kc1t Жыл бұрын
And what about the context? Is there a way to improve performance of that? Because since context update one of its values, the whole value gonna be considered as a new one, and all of the components that have hooked useContext will be rendered Iven they have memo on them
@SoftwareDeveloperDiaries
@SoftwareDeveloperDiaries Жыл бұрын
Thanks for a great question. I think this might be useful: stackoverflow.com/questions/57030018/react-context-with-hooks-prevent-re-render
@keerthanachar
@keerthanachar Жыл бұрын
Thank you
@SoftwareDeveloperDiaries
@SoftwareDeveloperDiaries Жыл бұрын
Thank you too 😊
@mohammadnoushadsiddiqi2550
@mohammadnoushadsiddiqi2550 10 ай бұрын
This will not help if we have like 15 - 20 input, radio, uploader, switches. Because using usecallback for all will be a problem. memorization technique comes with a cost.
@randompointlessness2766
@randompointlessness2766 6 ай бұрын
Thanks ! If I knew this, I would have saved my last job 😅
@PraveenKumaran-wh5gn
@PraveenKumaran-wh5gn Жыл бұрын
Good One Bro..
@SoftwareDeveloperDiaries
@SoftwareDeveloperDiaries Жыл бұрын
Thanks ✌️
@suryakumara3360
@suryakumara3360 Жыл бұрын
Hi, why not putting id, and value in callback dependencies ? so it will be triggered when the id or value changes.
@SoftwareDeveloperDiaries
@SoftwareDeveloperDiaries Жыл бұрын
Unless I misunderstood you, this way it will still rerender the whole component.
@suryakumara3360
@suryakumara3360 Жыл бұрын
@@SoftwareDeveloperDiaries Got it, I don't code in hand.
@jagjot1697
@jagjot1697 Жыл бұрын
id and value are probably of type 'String' or 'Number', which are both primitive types (includes string, number, boolean etc.) in JS. On each re-render of the parent, anything which is not a primitive data type - it could be an array, a function, or an object - all these are re-created (re-assigned a new reference/location/address in the memory) by the parent component because these are referenced by memory. All the primitive values are not re-created and hence, those do not change on the parent's re-render, which is why we don't need to 'cache' primitive values.
@coolmind2476
@coolmind2476 Ай бұрын
Just wondering why react doesnt do this optimizazion by default?
@oleksandrluchytskyi6867
@oleksandrluchytskyi6867 Жыл бұрын
can we pass parameters to the useCallback((id: number) => () => setSelectedId(id),[]); ?
@SoftwareDeveloperDiaries
@SoftwareDeveloperDiaries Жыл бұрын
Yes, you can: beta.reactjs.org/reference/react/useCallback
@oleksandrluchytskyi6867
@oleksandrluchytskyi6867 Жыл бұрын
@@SoftwareDeveloperDiaries ah… this example works for me, thanks 👍 e.g. (I need to call useCallback for each list item in a loop, but it’s not allowed)
@hund1267
@hund1267 Жыл бұрын
Handler shouldn't recreate if you lift it above the component, or?
@SoftwareDeveloperDiaries
@SoftwareDeveloperDiaries Жыл бұрын
Great point, it won't indeed! There are different opinions on this approach as well as small implications tho: stackoverflow.com/a/62925172
@mase-ob1vf
@mase-ob1vf Жыл бұрын
KING
@SoftwareDeveloperDiaries
@SoftwareDeveloperDiaries Жыл бұрын
Let's gooo 🤠
@symphony86
@symphony86 Жыл бұрын
I never have to think about all these doing angular or vue.. never have any issue with performance or lagging.. only react.. whyyyy
@SoftwareDeveloperDiaries
@SoftwareDeveloperDiaries Жыл бұрын
Eheheheee
@netssrmrz
@netssrmrz 8 ай бұрын
Nice video about a very common issue. Personally, issues like this is why I believe React needs to go the way of the dodo. Devs shouldn't assume that giving up control over when to render is going to magically make everything simple.
@SoftwareDeveloperDiaries
@SoftwareDeveloperDiaries 8 ай бұрын
Great point!
@vaibhavsalve2024
@vaibhavsalve2024 3 ай бұрын
Helpfull video. I Nee help.
@juliansyah4byte57
@juliansyah4byte57 Жыл бұрын
You get my sub and turn on bell
@SoftwareDeveloperDiaries
@SoftwareDeveloperDiaries Жыл бұрын
Happy to have you here!
@rjwhite4424
@rjwhite4424 Ай бұрын
I can't wait for React 19's compiler to come out so I don't have to bother with this.
@Amamamamwnwb
@Amamamamwnwb Жыл бұрын
Don’t set the editor to dark mode unless you set browser too. With screen bliking black and white, my eyes hurt. Thanks for great video though.
@SoftwareDeveloperDiaries
@SoftwareDeveloperDiaries Жыл бұрын
Thanks for the hint!
@anjanakaruna4095
@anjanakaruna4095 Жыл бұрын
my god! why we dont use these things in our code... thanks for sharing! open some new areas to study.
@SoftwareDeveloperDiaries
@SoftwareDeveloperDiaries Жыл бұрын
Happy to hear mate!
@timelimitexceeded0
@timelimitexceeded0 11 ай бұрын
Why not just take out the function out of the component instead of using useCallback
@SoftwareDeveloperDiaries
@SoftwareDeveloperDiaries 11 ай бұрын
Indeed! There are different opinions on this approach as well as small implications tho: stackoverflow.com/a/62925172
@AkioJunichiro
@AkioJunichiro Жыл бұрын
Seems interesting but you speak wet, it's hard to focus
@SoftwareDeveloperDiaries
@SoftwareDeveloperDiaries Жыл бұрын
Thanks for the feedback, I'll try to improve it! 🙂
@jarosawwanatowicz4139
@jarosawwanatowicz4139 Жыл бұрын
Spot the same
@bradyfractal6653
@bradyfractal6653 Жыл бұрын
I think you mispronounced “use Svelte” 😂
@SoftwareDeveloperDiaries
@SoftwareDeveloperDiaries Жыл бұрын
Oh :D
React Architecture: Small vs. Mid vs. Large App Folder Structure
8:30
Software Developer Diaries
Рет қаралды 26 М.
3 Ways to Make React App FASTER
14:43
Piyush Garg
Рет қаралды 28 М.
ELE QUEBROU A TAÇA DE FUTEBOL
00:45
Matheus Kriwat
Рет қаралды 17 МЛН
Osman Kalyoncu Sonu Üzücü Saddest Videos Dream Engine 118 #shorts
00:30
OMG 😨 Era o tênis dela 🤬
00:19
Polar em português
Рет қаралды 10 МЛН
8 React Js performance optimization techniques YOU HAVE TO KNOW!
11:23
You might not need useEffect() ...
21:45
Academind
Рет қаралды 144 М.
Goodbye, useEffect - David Khourshid
29:59
BeJS
Рет қаралды 493 М.
Preventing React re-renders with composition
12:11
Developer Way
Рет қаралды 14 М.
The ultimate guide to web performance
6:43
Beyond Fireship
Рет қаралды 397 М.
The correct way to optimise React
11:29
Cosden Solutions
Рет қаралды 28 М.
Microservices with Databases can be challenging...
20:52
Software Developer Diaries
Рет қаралды 14 М.
Thoughts About Unit Testing | Prime Reacts
11:21
ThePrimeTime
Рет қаралды 204 М.
📱 SAMSUNG, ЧТО С ЛИЦОМ? 🤡
0:46
Яблочный Маньяк
Рет қаралды 1,7 МЛН
Kalem ile Apple Pen Nasıl Yapılır?😱
0:20
Safak Novruz
Рет қаралды 1,2 МЛН
5 НЕЛЕГАЛЬНЫХ гаджетов, за которые вас посадят
0:59
Кибер Андерсон
Рет қаралды 313 М.