Watches for changes to the DOM tree using MutationObserver.
MutationObserver
The DOM node to observe.
The callback to execute when mutations occur.
The mutation observer configuration options.
This hook creates a MutationObserver and observes the target node. It automatically updates the observer when the configuration changes.
useMutationObserver( ref.current, (mutations) => { console.log("DOM changed!", mutations); }, { childList: true, subtree: true }); Copy
useMutationObserver( ref.current, (mutations) => { console.log("DOM changed!", mutations); }, { childList: true, subtree: true });
Watches for changes to the DOM tree using
MutationObserver.