When will you hit the componentDidMount hook in react? is it when the component is mounted to the virtual dom or actual dom?
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.