Can someone point me to where React actually updates the DOM?
See original GitHub issueI want to learn more about performance in React, so I’m trying to get a sense of exactly how and when React manipulates the DOM.
Stepping through the source (or inspecting in the devtools profiler), I can see that scheduleFlush
is finally called when React triggers an update to the DOM. I understand how reconciliation works, but I’m looking for the actual mechanics (read: specific line of code) where React appends new elements to the DOM (e.g. rootElement.appendChild(newElement)
). Can someone point me in the right direction?
I asked this on the #reactjs freenode, but didn’t get the response I was looking for. Thanks in advance!
Issue Analytics
- State:
- Created 6 years ago
- Comments:5 (3 by maintainers)
Top Results From Across the Web
React Virtual DOM Explained in Simple English
Once React knows which virtual DOM objects have changed, then React updates only those objects, in the real DOM. This makes the performance...
Read more >How to tell when React updates the real DOM - Stack Overflow
Looking at the DOM elements when I change a value on a square, I have no idea whether React is updating the entire...
Read more >What is the virtual DOM in React? - LogRocket Blog
This article will cover what the virtual DOM is, its benefits in React, ... React will ensure only the time gets updated in...
Read more >Virtual DOM and Internals - React
The virtual DOM (VDOM) is a programming concept where an ideal, or “virtual”, representation of a UI is kept in memory and synced...
Read more >ReactJS Tutorial: What is DOM? Real DOM & Virtual DOM ...
So when there is a update in the virtual DOM, react compares the ... Support my channel by liking and sharing my videos...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Most of the heavy lifting is here: https://github.com/facebook/react/blob/master/src/renderers/dom/fiber/ReactDOMFiberComponent.js ReactDOM injects it’s a “host” component class into React. React itself handles the traversal and diffing, then calls the various update methods on ReactDOMFiberComponent, which does all the work of moving the host node (DOM node) to it’s new markup.
No, React only updates the leaf nodes in this case.
Please see:
https://reactjs.org/docs/rendering-elements.html#react-only-updates-whats-necessary
https://reactjs.org/docs/reconciliation.html