Re:When does React re-render? Explaining rerenders and how t...
by jzer0cool on Wednesday April 29, 2020 @06:34AM
(#23017591)
To be more specific, when ReactDOM.render() is called from a component -- is the argument that the entire screen does not have to be painted?
Re:When does React re-render? Explaining rerenders and how t...
by fgerschau on Wednesday April 29, 2020 @08:52AM
(#23018483)
By that I mean that there's a difference between calling React's render function and rendering something to the browser DOM (native renders).
React will try to reduce the number of renders to the real DOM as much as possible, so calling a component's render functions doesn't always imply a re-paint of the UI.
Expanding a text box wouldn't usually trigger a re-render because this is being handled by the browser and doesn't affect the state of the application (just like any CSS rules). Reordering elements on the other hand will trigger a re-render because the actual HTML element's position has to change.
So yes, the argument is that the entire screen doesn't have to be repainted. In the ideal case it only repaints the parts of the UI that need to change.
Could we clear up more the meaning of rendering and how it optimizes the performance mentioned in the article? Suppose the DOM has not changed, is the DOM repainted? How about in the case you type into a textbox which expands this container, causing adjacent elements to cascade into a new position?
Is this something similar to how mobile devices do not have to render content that is "not" displayed on the screen, as in the example of a large ListView so the mobile device does not have to immediate render any content that is expected to be off screen.