You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

useMutationObserver.d.ts 634 B

3 years ago
12345678910111213141516171819202122
  1. /**
  2. * Observe mutations on a DOM node or tree of DOM nodes.
  3. * Depends on the `MutationObserver` api.
  4. *
  5. * ```ts
  6. * const [element, attachRef] = useCallbackRef(null);
  7. *
  8. * useMutationObserver(element, { subtree: true }, (records) => {
  9. *
  10. * });
  11. *
  12. * return (
  13. * <div ref={attachRef} />
  14. * )
  15. * ```
  16. *
  17. * @param element The DOM element to observe
  18. * @param config The observer configuration
  19. * @param callback A callback fired when a mutation occurs
  20. */
  21. declare function useMutationObserver(element: Element | null | undefined, config: MutationObserverInit, callback: MutationCallback): void;
  22. export default useMutationObserver;