description |
---|
Observe the changes of a reference using MutationObserver |
import {
useMutationObserver,
useMutationObserverState
} from "@atomico/hooks/use-mutation-observer";
Observe mutations using a callback
useMutationObserver(
ref: Ref<Element>,
observe: MutationCallback,
config?: MutationObserverInit
);
Reflects mutations in a state
const mutations:MutationRecord[] = useMutationObserverState(
ref: Ref<Element>,
config?: MutationObserverInit
);
{% embed url="https://webcomponents.dev/edit/collection/n2tZyzx4LMKqk1jNE0e9/DuOt53NoiMeLZfQKfVuf/src/index.jsx" %}