Under Adding Lifecycle Methods to a Class in the official Facebook docs for React, it's mentioned:
5) If the Clock component is ever removed from the DOM, React calls the componentWillUnmount() lifecycle hook so the timer is stopped.
Just trying to understand how? I get that React knows when it's about to insert the component in the DOM, so it can callcomponentDidMount life cycle hook then.
But for componentWillUnmount it just says "ever removed from the DOM". Seems to suggest it's the real DOM not React DOM. One might as well remove the component with javaScript/jQuery and componentWillUnmount should fire.
How exactly does React know the component has been removed from the real DOM? Could there be a watcher?
Thanks