Description
@rc-component/mutate-observer is a React wrapper and hook for watching changes to the DOM. It gives you a typed way to use the browser's MutationObserver API from React. You can use it as a component, wrapping the element you want to watch, or as a hook that observes a target element or an array of elements. Both take the same callback and the native MutationObserverInit options, such as attributes, childList and subtree. The callback receives the list of MutationRecord entries along with the native MutationObserver instance, so you can react to exactly the changes you care about. The package includes TypeScript definitions for the component props and the hook. The project is part of the Ant Design ecosystem and says Ant Design uses it as a small DOM observation building block. Installation and usage are covered in the README, and the examples run from a local dumi site on port 8000. The package is released under the MIT license.…
Highlights
- React component and hook for DOM mutations
- Typed MutationObserver API
- Full native MutationObserverInit options
- Callback receives MutationRecord list and observer
- TypeScript definitions included
- MIT-licensed, used in Ant Design
Ratings & Reviews
No ratings yet
Be the first to rate @rc-component/mutate-observer.
People also visit

react-on-screen
A wrapper component to track if your react component is visible on screen
react-resize-aware
A React hook that makes it possible to listen to element resize events

react-scrollchor
A React component for scrolling to #hash links with smooth animations
@rc-component/mutate-observer FAQ
What does this package do?
It lets a React component watch changes to a rendered DOM node, using the browser's MutationObserver API.
Can I use it as a hook?
Yes. useMutateObserver observes the element or elements you pass it, with the same callback and options as the component.
Which options can I set?
Any native MutationObserverInit option, such as attributes, childList and subtree.
What does the callback receive?
The list of MutationRecord entries and the native MutationObserver instance.
Is it part of Ant Design?
It is part of the Ant Design ecosystem, and Ant Design uses it as a DOM observation primitive.
What license is it under?
MIT.
What are the best @rc-component/mutate-observer alternatives?
Popular alternatives to @rc-component/mutate-observer include react-on-screen, react-resize-aware and react-visibility-sensor. See all @rc-component/mutate-observer alternatives














