diff --git a/packages/react/src/ErrorBoundaryGroup.tsx b/packages/react/src/ErrorBoundaryGroup.tsx index 7ed83c57b..9ac6e41b4 100644 --- a/packages/react/src/ErrorBoundaryGroup.tsx +++ b/packages/react/src/ErrorBoundaryGroup.tsx @@ -1,6 +1,6 @@ import type { ComponentProps, ComponentType, PropsWithChildren } from 'react' -import { createContext, useContext, useEffect, useMemo } from 'react' -import { useIsChanged, useKey } from './hooks' +import { createContext, useContext, useMemo } from 'react' +import { useIsChanged, useIsomorphicLayoutEffect, useKey } from './hooks' import type { PropsWithoutChildren } from './types' import { assert } from './utils' @@ -27,7 +27,7 @@ export const ErrorBoundaryGroup = ({ blockOutside = false, children }: ErrorBoun const parentGroup = useContext(ErrorBoundaryGroupContext) const isParentGroupResetKeyChanged = useIsChanged(parentGroup?.resetKey) - useEffect(() => { + useIsomorphicLayoutEffect(() => { if (!blockOutside && isParentGroupResetKeyChanged) { reset() }