question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Can someone point me to where React actually updates the DOM?

See original GitHub issue

I 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:closed
  • Created 6 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
jquensecommented, Oct 9, 2017

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.

1reaction
gaearoncommented, Oct 9, 2017
Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found