When will you hit the componentDidMount hook in react? is it when the component is mounted to the virtual dom or actual dom?
Asked
Active
Viewed 199 times
1 Answers
3
The component is mounted to the Virtual DOM on render()
, at the "Render phase".
The componentDidMount
lifecycle, which is part of the "Commit phase", is mounted to the actual DOM.
Notice that you can have another render phase if you call setState
in the componentDidMount
.
You may call
setState()
immediately incomponentDidMount()
. It will trigger an extra rendering, but it will happen before the browser updates the screen.

Dennis Vash
- 50,196
- 9
- 100
- 118
-
So componentDidMount will trigger soon after the component is mounted to the virtual dom? Is that what you meant? – Charitha Goonewardena Jul 07 '20 at 07:43
-
Soon after, yes – Dennis Vash Jul 07 '20 at 07:44
-
One last question, so after triggering componentDidMount that specific node of the Virtual DOM will sync with real DOM in reconciliation. Is that what happens behind the scene? – Charitha Goonewardena Jul 07 '20 at 07:49
-
1Yes, this what happens. – Dennis Vash Jul 07 '20 at 07:51