use-mutation-observer
Observe the changes of a reference using MutationObserver

Module

1
import {
2
useMutationObserver,
3
useMutationObserverState
4
} from "@atomico/hooks/use-mutation-observer";
Copied!

useMutationObserver syntax

Observe mutations using a callback
1
useMutationObserver(
2
ref: Ref<Element>,
3
observe: MutationCallback,
4
config?: MutationObserverInit
5
);
Copied!

useMutationObserver syntax

Reflects mutations in a state
1
const mutations:MutationRecord[] = useMutationObserverState(
2
ref: Ref<Element>,
3
config?: MutationObserverInit
4
);
Copied!

Example

WebComponents.dev
WebComponents.dev