From 767c848339591f1b26cacf7da2f0436c5535008a Mon Sep 17 00:00:00 2001 From: Roman Knel Date: Fri, 22 Nov 2024 13:39:46 +0300 Subject: [PATCH] fix(SingleToast): avoid flushSync error in react@16 (#3546) --- packages/react-ui/components/SingleToast/SingleToast.tsx | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/packages/react-ui/components/SingleToast/SingleToast.tsx b/packages/react-ui/components/SingleToast/SingleToast.tsx index 8c83f17f6b9..1de6b8600f5 100644 --- a/packages/react-ui/components/SingleToast/SingleToast.tsx +++ b/packages/react-ui/components/SingleToast/SingleToast.tsx @@ -16,7 +16,11 @@ export class SingleToast extends React.Component { SingleToast.ref.current?.push(...args); }; public static close: typeof Toast.close = () => { - ReactDOM.flushSync(() => SingleToast.ref.current?.close()); + if (React.version.search('18') === 0) { + ReactDOM.flushSync(() => SingleToast.ref.current?.close()); + } else { + SingleToast.ref.current?.close(); + } }; render = () => { return ;