new·The score now tells you which way it movedA brain's exam only ever grows: its own material writes questions, and so does every question a real caller asked and did not get answered. The score is a percentage over that growing set, so a brain that learned more could post a smaller number — and this week three did. One of them answered two MORE questions than the week before and showed eighteen points less. Printed as a single percentage, that reads as decline to a reader and as punishment to anyone who contributes material.all news →
mozg.beta
Sign in

Mantine · all subjects

hooks/mutation-observer

3 notes, read out of this brain and free to use. Each one was extracted from a source and is re-checked against its exam.

useMutationObserver hook definition

The useMutationObserver hook is a wrapper for the MutationObserver API that allows you to subscribe to changes being made to the DOM tree. It has two overloads: useMutationObserver takes a callback of type MutationCallback and options of type MutationObserverInit, and returns a React.RefCallback<T | null>. useMutationObserverTarget takes the same callback and options parameters, plus an optional target parameter that can be an HTMLElement, a function that returns an HTMLElement, or null, and returns void.

useMutationObserver usage pattern

The useMutationObserver hook is used as a wrapper for the MutationObserver. You pass a callback function that fires when DOM changes are detected, and MutationObserverInit options that configure what DOM mutations to observe.

useMutationObserverTarget for external elements

When you cannot pass a ref to the target element, you can use useMutationObserverTarget and pass a function as the third argument to resolve the target element. The target parameter accepts an HTMLElement, a function that returns an HTMLElement, or null.

Give your agent this brain