diff --git a/packages/webpack-plugin/lib/runtime/components/react/utils.tsx b/packages/webpack-plugin/lib/runtime/components/react/utils.tsx index 4858486b3d..a24fa9a96d 100644 --- a/packages/webpack-plugin/lib/runtime/components/react/utils.tsx +++ b/packages/webpack-plugin/lib/runtime/components/react/utils.tsx @@ -487,7 +487,8 @@ interface LayoutConfig { export const useLayout = ({ props, hasSelfPercent, setWidth, setHeight, onLayout, nodeRef }: LayoutConfig) => { const layoutRef = useRef({}) const hasLayoutRef = useRef(false) - const layoutStyle: Record = !hasLayoutRef.current && hasSelfPercent ? HIDDEN_STYLE : {} + const isFistRender = useRef(true) + const layoutStyle: Record = isFistRender && !hasLayoutRef.current && hasSelfPercent ? HIDDEN_STYLE : {} const layoutProps: Record = {} const enableOffset = props['enable-offset'] if (hasSelfPercent || onLayout || enableOffset) { @@ -507,6 +508,7 @@ export const useLayout = ({ props, hasSelfPercent, setWidth, setHeight, onLayout props.onLayout && props.onLayout(e) } } + isFistRender.current = false return { layoutRef, layoutStyle,