import { type Ref, type RefCallback } from "react"; /** * @since 6.0.0 */ export interface MutationObserverHookOptions extends MutationObserverInit { ref?: Ref; /** * @see https://developer.mozilla.org/en-US/docs/Web/API/MutationObserver/observe#options * @defaultValue `!childList && !attributes && !characterData` */ disabled?: boolean; onUpdate: (mutation: MutationRecord) => void; } /** * The mutation observer is used to track the changes made to the DOM tree. * * @example Simple Example * ```tsx * import { useMutationObserver } from "@react-md/core/useMutationObserver"; * import { useCallback, type HTMLAttributes, type ReactElement } from "react"; * * function Example(props: HTMLAttributes): ReactElement { * const { children, ...remaining } = props; * * const targetRef = useMutationObserver({ * subtree: true, * attributes: true, * childList: true, * onUpdate: useCallback((mutation) => { * switch (mutation.type) { * case "childList": * console.log("A child node has been added or removed"); * break; * case "attributes": * console.log(`The ${mutation.attributeName} attribute was modified`); * break * } * * }, []), * }); * * return ( *
* {children} *
* ); * } * ``` * * @since 6.0.0 */ export declare function useMutationObserver(options: MutationObserverHookOptions): RefCallback;