Skip to content

Commit e1ffce4

Browse files
Remove flushSync usage in ShadowRoot component
Replaces flushSync with a regular setState call when initializing the shadow root. This simplifies the effect and removes unnecessary synchronous state updates.
1 parent 0b9c1e0 commit e1ffce4

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

src/test/helper_components/shadow_root.tsx

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import React, {
55
useRef,
66
useState,
77
} from "react";
8-
import { createPortal, flushSync } from "react-dom";
8+
import { createPortal } from "react-dom";
99

1010
const ShadowRoot: FC<PropsWithChildren> = ({ children }) => {
1111
const [shadowRoot, setShadowRoot] = useState<ShadowRoot | null>(null);
@@ -22,9 +22,7 @@ const ShadowRoot: FC<PropsWithChildren> = ({ children }) => {
2222
const root =
2323
container.shadowRoot ?? container.attachShadow({ mode: "open" });
2424
isInitializedRef.current = true;
25-
// Use flushSync to synchronously update state within effect, avoiding cascading renders
26-
// while ensuring the shadow root is available immediately for tests
27-
flushSync(() => setShadowRoot(root));
25+
setShadowRoot(root);
2826
}, []);
2927

3028
return (

0 commit comments

Comments
 (0)