Skip to content

Commit

Permalink
fix(utils): fix unmount warning. #367
Browse files Browse the repository at this point in the history
  • Loading branch information
jaywcjlove committed Jul 3, 2024
1 parent c4fd3d9 commit df7f4fe
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion packages/utils/src/usePortal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,11 @@ export const usePortal = () => {
return createPortal(children, elmm);
};
const remove: State['remove'] = (elm) => {
elm && ref.current?.unmount();
// https://stackoverflow.com/a/74445760/1334703
const timeout = setTimeout(() => {
elm && ref.current?.unmount();
clearTimeout(timeout);
});
};
return { render: Portal, remove };
}, []);
Expand Down

0 comments on commit df7f4fe

Please sign in to comment.