Stop worrying about React Re-renders so much (an overview of the react profiler with refactoring)

  Рет қаралды 15,178

Web Dev Cody

Web Dev Cody

Жыл бұрын

Just sharing some thoughts about rerenders in react and performance tuning. A lot of people comment about react performance with rerenders. Remember this quote: "Make it work, make it right, make it fast"
------------
🤑 Patreon / webdevjunkie
🔔 Newsletter eepurl.com/hnderP
💬 Discord / discord
📁. GitHub github.com/codyseibert/youtube

Пікірлер: 48
@adivp7
@adivp7 Жыл бұрын
Developers will usually have faster machines than users. And users will do more than just use your one app. Not worrying about performance and resource usage is how we get terrible apps like MS Teams
@codingispower1816
@codingispower1816 4 ай бұрын
True, using the performance tab in chrome to purposely use 1 core and 4x slow down your code and then comparing in the profiler is helpful to simulate worst case scenarios.
@clusterdriven
@clusterdriven 2 ай бұрын
So true
@vivekkumar-pc1xy
@vivekkumar-pc1xy 7 ай бұрын
Great video! I've been exploring various blogs and videos to gain insights into React re-rendering. Your video provides an excellent real-world perspective on the topic.
@David-zv5kw
@David-zv5kw Жыл бұрын
awesome video! thank you so much!
@varileshtlesht7091
@varileshtlesht7091 Жыл бұрын
Thank you for your video it was very clear. Can you please do a video when you explain in details the useMemo and useCallback and when to use them. I would appreciate it.
@datfeela2578
@datfeela2578 Жыл бұрын
Great video, keep it up!
@Icemourne_
@Icemourne_ Жыл бұрын
In my experience, you as a developer can simply never see any slowdowns while some of your users are getting a terrible experience. In my specific case problem is the AMD CPUs especially on Firefox.
@CottidaeSEA
@CottidaeSEA Жыл бұрын
The human eye only being able to recognise 30 fps is a myth. We're able to notice far more than that. It's said that 24 fps is required for us to interpret video as motion. I don't know how precise that number is however. I can see a clear difference between frame rates even upwards of 100 fps, after that the updates are too frequent for me to notice a difference. However, some people can notice even more frequent changes. We might not necessarily be able to react to all changes however. Our eyes don't use a concept such as frames to begin with, we continually interpret changes, and how well we process the information depends on ability, and that can be improved through training. However, being bothered by a change that takes far less than 1/30 of a second is pointless as you said. I'd say about 50ms is within an acceptable range when it comes to responsiveness.
@RaZziaN1
@RaZziaN1 Жыл бұрын
yeah but we have two eyes so it is 60fps, and mine are super fast so 144
@CottidaeSEA
@CottidaeSEA Жыл бұрын
@@RaZziaN1 Big brain time!
@WebDevCody
@WebDevCody Жыл бұрын
I’d have to go check for myself with my own broken eyeballs. When playing a game I can easily notice the difference between when my pc is running at 30 vs 60 fps, but idk about if I’m just watching a video. But yeah my main point is a lot of people will be fast to comment when doing something in state will cause extra rerendering when in reality it doesn’t make a impactful difference to the Ux. Most of the time in a web app is waiting for the server to send back json or confirm my post requests. When it is slow, make it faster and don’t get caught up on premature optimization
@CottidaeSEA
@CottidaeSEA Жыл бұрын
@@WebDevCody Agreed. Besides, most performance issues are due to design choices rather than re-renders.
@VictorZamanian
@VictorZamanian 5 ай бұрын
@@WebDevCody Yeah, the human eye can recognize MUCH more than 30 fps. I can easily notice the difference between 144 Hz and 240 Hz when I switch it up before starting up a game e.g. Don't get me started on 60 Hz (literally a slideshow when playing a game) and 144 hz. Day and night. The weird thing is, watching a gaming _video_ at 60 Hz looks super smooth, but _playing_ it? Choppy af, man.
@user-oy4kf5wr8l
@user-oy4kf5wr8l Жыл бұрын
Great video, thx!
@SeibertSwirl
@SeibertSwirl Жыл бұрын
Good job babe!!!
@carljkempe
@carljkempe Жыл бұрын
Goals
@deepanshhh
@deepanshhh Ай бұрын
Great video but not for everyone. I develop web apps using react three fiber (a react based wrapper around threejs) for building 3d experiences. Where your application needs to run at 60-90 fps, and even the smallest things can cause a frame rate drop, avoiding react to re-render lots of times becomes a very important thing
@Chrosam
@Chrosam Жыл бұрын
I always say that computation isn't the biggest issue anymore. But rather network calls are. However, I still find myself trying to optimize rendering prematurely..
@brownboyintokyo7368
@brownboyintokyo7368 Жыл бұрын
When do u recommend shifting to state sharing tools like Redux Toolkit over React context?
@WebDevCody
@WebDevCody Жыл бұрын
When and if you find redux actually improves your code maintainability. If your app still runs fine and it’s easier to understand where state is coming from I see no need to switch from context. Some people will say content causes extra rerendering but until you prove it’s a problem, it’s not a problem
@mohammed.haydar
@mohammed.haydar Жыл бұрын
@@WebDevCody I love this explanation, I use useContext and depend solely on it in my app. Whenever I see people use Redux and whatever tools are there, I get worried bcuz then I need to learn all those new concepts! lol, I'm just not in a mood to learn something like Redux
@brownboyintokyo7368
@brownboyintokyo7368 Жыл бұрын
@@WebDevCody Thank you! Yes, many developers do claim about context causing extra rendering so I was wondering whether it is better to switch to a proper state management toolkit like redux or not. But yes you are right cuz there is no point in switching unless the app runs into some major issue.
@codingispower1816
@codingispower1816 4 ай бұрын
How to decide when to use memo vs just pulling the component to a higher state?
@WebDevCody
@WebDevCody 4 ай бұрын
I think memo just gives more flexibility to move the component where ever
@discoRyne
@discoRyne Жыл бұрын
3:13 as a gamer, this statement is complete pain. Nice vid tho.
@WebDevCody
@WebDevCody Жыл бұрын
Thanks!
@amans6504
@amans6504 Жыл бұрын
So re rendering here only means re rendering the vdom right?
@WebDevCody
@WebDevCody Жыл бұрын
Yes, at least that’s what they mean when they say rerender in the react docs
@yeet141
@yeet141 Жыл бұрын
Great video, but what you said about 30fps is a myth. Apologies if the joke flew over my head.
@cirovevatovevato4554
@cirovevatovevato4554 Жыл бұрын
@1:25, shouldn't you have said "... what the VIRTUAL DOM looks like..." instead of SHADOW DOM?
@WebDevCody
@WebDevCody Жыл бұрын
Yeah probably
@kaos092
@kaos092 Жыл бұрын
It's not a shadow DOM It's a virtual DOM. Two completely different things.
@jonny9425
@jonny9425 Ай бұрын
The only thing this video does is explain why you SHOULD be concerned about re-renders
@itay_hd
@itay_hd Жыл бұрын
3:15 The human eye can see way above 30fps
@WebDevCody
@WebDevCody Жыл бұрын
From what I read it’s 30-60
@itay_hd
@itay_hd Жыл бұрын
@@WebDevCody common mistake bro
@WebDevCody
@WebDevCody Жыл бұрын
@@itay_hd I’m not convinced. You show a 30 fps movie to my grandma vs a 60 fps movie, I don’t think they’ll be able to tell the difference
@itay_hd
@itay_hd Жыл бұрын
@@WebDevCody excuse me wtf? Are you serious? I had a 60hz monitor and switched to 144hz and there is a diffrence. If you and you have 40 fps you will feel BIG diffrence between that and 60. Are you being fr?
@oumardicko5593
@oumardicko5593 Жыл бұрын
i'm not a react dev, right now, the big problem react has for me is not re-render, it's all those crazy hooks they have.
@imhassane
@imhassane Жыл бұрын
In a project you use only three actually
@WebDevCody
@WebDevCody Жыл бұрын
Avoid useEffect at all costs lol
@oumardicko5593
@oumardicko5593 Жыл бұрын
well, i'm not a react dev so i'll trust you on that but can you imagine how frustrating it can be for a newbie to start learning react and see theses hooks all over the place and then learn latter that they have to worry about re-rendering !!!
@imhassane
@imhassane Жыл бұрын
@@oumardicko5593 I’m an react native intern and I actually only use useEffect and useState most of the times, sometimes there is a useRef but I just use the first two and yes we should learn about re-renderings but most of the times it’s not that bad, I’ve rarely seen slow re-renders and usually you just have to change a bit of logic and it’s good and this is fun to learn about. I don’t want to work on a technology that doesn’t challenge me, I want to learn more and react is fun 🤩
@ilearncode7365
@ilearncode7365 Жыл бұрын
"A human cannot detect higher than 30FPS". All future opinions stated, discarded
@WebDevCody
@WebDevCody Жыл бұрын
Sure, maybe it’s like 60 fps, but that wasn’t my point in this video
@kabiskac
@kabiskac Жыл бұрын
@@WebDevCody or hundreds
@discoRyne
@discoRyne Жыл бұрын
@@kabiskac Potentially ~1000fps. When it comes to gaming average gamers will only be able to tell the difference up to 120-150fps/hz. The more competitive you play, the more you'll recognize higher FPS (when matched with the same refresh rate, of course.) My jump from 144hz to 240hz was huge, but not as drastic as 60hz to 144hz. The difference is astonishing as well as the extra power needed to keep up with higher framerates on both the display and CPU/GPU. Given 60hz dominance and standard, I'd consider 60fps to be the minimum target if you're looking for clarity. 50hz/50fps for PAL-region stuff if the standards still hold up to this day.
The important things to know about React state and renders
18:33
Web Dev Cody
Рет қаралды 25 М.
Stop Doing this as a React Developer
12:27
CoderOne
Рет қаралды 158 М.
FOOTBALL WITH PLAY BUTTONS ▶️ #roadto100m
00:29
Celine Dept
Рет қаралды 54 МЛН
маленький брат прыгает в бассейн
00:15
GL Show Russian
Рет қаралды 4,4 МЛН
Follow @karina-kola please 🙏🥺
00:21
Andrey Grechka
Рет қаралды 22 МЛН
ПЕЙ МОЛОКО КАК ФОКУСНИК
00:37
Masomka
Рет қаралды 9 МЛН
3 Levels of Vim Refactoring
7:48
typecraft
Рет қаралды 33 М.
Efficiently Render 100,000 Rows in React
16:41
Cosden Solutions
Рет қаралды 14 М.
Preventing React re-renders with composition
12:11
Developer Way
Рет қаралды 14 М.
You Probably Shouldn't Use React.memo()
10:17
Theo - t3․gg
Рет қаралды 52 М.
Un-Suck Your React Components - Composable & Compound Components
15:47
Turning bad React code into senior React code
13:10
Cosden Solutions
Рет қаралды 83 М.
The correct way to optimise React
11:29
Cosden Solutions
Рет қаралды 28 М.
Goodbye, useEffect - David Khourshid
29:59
BeJS
Рет қаралды 492 М.
FOOTBALL WITH PLAY BUTTONS ▶️ #roadto100m
00:29
Celine Dept
Рет қаралды 54 МЛН