diff --git a/.eslintignore b/.eslintignore index 4a79361a50..0a27282b21 100644 --- a/.eslintignore +++ b/.eslintignore @@ -23,6 +23,7 @@ lib/**/* node_modules _site dist +coverage **/*.d.ts # Scripts scripts/previewEditor/**/* \ No newline at end of file diff --git a/components/_util/usePatchElement.tsx b/components/_util/usePatchElement.tsx index 55f74d1686..18c1645dd9 100644 --- a/components/_util/usePatchElement.tsx +++ b/components/_util/usePatchElement.tsx @@ -7,8 +7,11 @@ export default function usePatchElement(): [ const [elements, setElements] = React.useState([]); function patchElement(element: React.ReactElement) { + // append a new element to elements (and create a new ref) setElements(originElements => [...originElements, element]); + // return a function that removes the new element out of elements (and create a new ref) + // it works a little like useEffect return () => { setElements(originElements => originElements.filter(ele => ele !== element)); }; diff --git a/components/avatar/__tests__/__snapshots__/demo.test.js.snap b/components/avatar/__tests__/__snapshots__/demo.test.js.snap index 9800a29f34..a777a02e99 100644 --- a/components/avatar/__tests__/__snapshots__/demo.test.js.snap +++ b/components/avatar/__tests__/__snapshots__/demo.test.js.snap @@ -469,6 +469,120 @@ Array [ ] `; +exports[`renders ./components/avatar/demo/group.md correctly 1`] = ` +Array [ +
+ + + + + + K + + + + + + + + + + + + +
, +