useDOMObserver
The useDOMObserver hook allows you to observe changes to a DOM element and execute a callback function whenever mutations occur. This can be useful for scenarios where you need to react to changes in the DOM, such as when elements are added, removed, or modified.
Usage
First, you need to import the useDOMObserver hook from the kitchn package.
import { useDOMObserver } from "kitchn";Example
Here is an example of how to use the useDOMObserver hook in a component:
Parameters
The useDOMObserver hook accepts the following parameter:
| Name | Type | Description |
|---|---|---|
ref | React.MutableRefObject<HTMLElement> | A ref object that points to the DOM element you want to observe. |
callback | MutationCallback | A function to be called whenever mutations are observed. |
Return Value
The useDOMObserver hook does not return any value.