@rooks/use-mutation-observer-ref
Version:
A hook that tracks mutations of an element. It returns a callbackRef.
16 lines (13 loc) • 510 B
TypeScript
declare type HTMLElementOrNull = HTMLElement | null;
declare type CallbackRef = (node: HTMLElementOrNull) => any;
/**
*
* useMutationObserverRef hook
*
* Returns a mutation observer for a React Ref and fires a callback
*
* @param {MutationCallback} callback Function that needs to be fired on mutation
* @param {MutationObserverInit} options
*/
declare function useMutationObserverRef(callback: MutationCallback, options?: MutationObserverInit): [CallbackRef];
export default useMutationObserverRef;