I write all my newsletters using Kit โ, my favorite newsletter platform.
Subscribe to the newsletter
Get the latest updates delivered directly to your inbox.
I write all my newsletters using Kit โ, my favorite newsletter platform.
Get the latest updates delivered directly to your inbox.
Hey friend,
A few years ago, I travelled to 15 different countries and gave talks at 15+ conferences across the globe ๐. It was the best time of my life, and even though I was uncomfortable, I pushed myself to go after what I wanted. It all stopped after 2020 hit ๐.
But guess what, I set a goal this year to give conference talks and travel again, and I'm happy to report that I'll be giving talks at 3 different conferences - Reactathon, ChainReact and App.js and all of them are on Performance ๐.
I'm quite passionate about Performance and wanted to ask you.
โ๐ฅ Hell yeah, do it!!!โ
โ๐ซค Not really, still trying to get better at Reactโ
โ๐ No, work on something elseโ
Thanks so much, You are the best! ๐
In JavaScript, we only have one main thread, and we're keeping it super busy by running this code repeatedly.
Both useMemo and useCallback reduce the times a component needs to re-render. We want to do as little as possible to draw the UI ๐จ.
with useMemo, we are telling React to only recalculate the value based on dependencies.
useMemo is like a cache, so we are telling only to do this task when this specific dependency changes. useMemo checks for arrays and objects.
Okay, enough theory ๐ , let's look at our snack ๐ฟ
With useMemo, the expensive computation would be executed every time the component re-renders, even if the color state has stayed the same.
๐ข This can lead to slow rendering times
โ And a poor user experience, especially when dealing with costly calculations.
Using useMemo
, we tell React to store the result of the expensive computation and only recompute it when the specified dependency (color
) changes.
โ๏ธ This helps to minimize the number of times the computation is executed
โฌ๏ธ This can significantly improve the component's performance and overall user experience.
I am so close to launching a program called Developer to Leader that will teach you how to become a successful Engineering Leader.
Check out the landing page ๐ฅ |
The program will be released in Early Access on May 2nd at 10:00 AM EST (7 AM PST, 3 PM GMT, 4 pm CET, 7:30 pm IST). If you like to take advantage of Early Access pricing, add yourself to the Waitlist. If you'd like, you can click here to add a calendar reminder. ๐
Add to the waitlist โจ |
This is a magical link that will automatically add you to the waitlist
โNext.js 13.3 is out ๐ฅ - check the latest updates here.
I have recorded 2 videos on my channel, and many more are coming up.
I hope you have a great day.