3 ms·
> You want to show something new to your customers / users without rerendering? Well sorry, that's impossible, regardless of any framework you use and you shoul
by dahart 4y ago
> You want to show something new to your customers / users without rerendering? Well sorry, that's impossible, regardless of any framework you use and you should
go back to UI development 101.
When you say “render” are you referring to what React means by “render”, that it will go through the whole virtual DOM cycle? Because it most certainly is possible to avoid that when using pure JavaScript. Why do you say it’s impossible? React’s fundamental problem with performance, and the whole reason people often don’t want to re-render is because React renders everything, then does a big diff on the DOM to compare it to what was rendered before, and then updates the elements that changed. I know a lot of work has been put into making that process fast, but it’s still really expensive compared to the pure JS way of doing it. In CS terminology, updating a button or any other single element went from an O(1) operation with JavaScript to an O(N) operation with React.
- strokirk 4y agoTo show something new to the user, state must be calculated and pushed either to the DOM or blitted to a canvas.
- dahart 4y agoNot sure I understand your point, can you elaborate? My point is that updating the state for a single element causes React to compute the state for the whole page, and diff the whole page virtual DOM against the whole page actual DOM, before pushing the update of that single element into the DOM. With pure JavaScript, you can skip all that and directly update a single element. This is often in practice much faster.