There is no observer in the real DOM. Each time a component rendering function is called, the virtual DOM is restored. If the component is no longer needed, it is removed from the virtual DOM.
The difference algorithm identifies the parts of the actual DOM that need to be changed so that the actual DOM is a reflection of the virtual DOM: some components must be added to the actual DOM (= called mounting), other components will need to be removed (= unmount). This whole process is called reconciliation .
It is because of this reconciliation process that React knows which components should be removed from the actual DOM. Right before the component is removed, React calls the hookObject () of the componentWillUnmount () life cycle.
If another script (Javascript or jQuery) removes a specific component from the actual DOM, React will never notice it and therefore will not call hookCycleUillmount ().
source share