File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11<div align =" center " >
22 <h1 >@rc-component/mutate-observer</h1 >
3+ <p ><sub >Part of the Ant Design ecosystem.</sub ></p >
34 <img alt =" Ant Design " height =" 32 " src =" https://gw.alipayobjects.com/zos/bmw-prod/ae669a89-0c24-40ff-a91d-2b83497170f6.svg " />
45 <p >👁️ React wrapper and hook for observing DOM mutations with a typed MutationObserver API.</p >
56</div >
67
7- <p align =" center " >
8- <sub >
9- <a href="https://ant.design">
10- <img alt="Ant Design" src="https://gw.alipayobjects.com/zos/rmsportal/KDpgvguMpGfqaHPjicRK.svg" height="16">
11- </a>
12- Part of the Ant Design ecosystem.
13- </sub >
14- </p >
158
169<div align =" center " >
1710
@@ -53,8 +46,6 @@ npm install @rc-component/mutate-observer
5346
5447``` tsx | pure
5548import MutateObserver from ' @rc-component/mutate-observer' ;
56- import React from ' react' ;
57-
5849export default () => (
5950 <MutateObserver
6051 options = { { attributes: true , childList: true , subtree: true }}
@@ -70,16 +61,13 @@ export default () => (
7061
7162``` tsx | pure
7263import { useMutateObserver } from ' @rc-component/mutate-observer' ;
73- import React , { useState } from ' react' ;
74-
75- export default () => {
76- const [target, setTarget] = useState <HTMLDivElement | null >(null );
7764
65+ export default ({ target }: { target: HTMLDivElement | null }) => {
7866 useMutateObserver (target , mutations => {
7967 console .log (mutations );
8068 });
8169
82- return <div ref = { setTarget } >Observed content</div >;
70+ return <div >Observed content</div >;
8371};
8472```
8573
You can’t perform that action at this time.
0 commit comments