From 7834e708e4fa50937d7a92b9327054dc2f8a6b45 Mon Sep 17 00:00:00 2001 From: shangqunfeng Date: Tue, 24 Dec 2024 22:19:28 +0800 Subject: [PATCH] fix(*): fix backgroud style. --- .../lib/runtime/components/react/mpx-view.tsx | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/packages/webpack-plugin/lib/runtime/components/react/mpx-view.tsx b/packages/webpack-plugin/lib/runtime/components/react/mpx-view.tsx index bd9efe5d0b..2cc8e276ae 100644 --- a/packages/webpack-plugin/lib/runtime/components/react/mpx-view.tsx +++ b/packages/webpack-plugin/lib/runtime/components/react/mpx-view.tsx @@ -643,7 +643,7 @@ function wrapImage (imageStyle?: ExtendedViewStyle, innerStyle?: Record @@ -653,6 +653,11 @@ interface WrapChildrenConfig { } function wrapWithChildren (props: _ViewProps, { hasVarDec, enableBackground, textStyle, backgroundStyle, varContext, textProps, innerStyle, enableFastImage }: WrapChildrenConfig) { + enableBackground = enableBackground || !!backgroundStyle + const enableBackgroundRef = useRef(enableBackground) + if (enableBackgroundRef.current !== enableBackground) { + error('[Mpx runtime error]: background use should be stable in the component lifecycle, or you can set [enable-background] with true.') + } const children = wrapChildren(props, { hasVarDec, varContext, @@ -715,12 +720,6 @@ const _View = forwardRef, _ViewProps>((viewProps, r const { textStyle, backgroundStyle, innerStyle = {} } = splitStyle(normalStyle) - enableBackground = enableBackground || !!backgroundStyle - const enableBackgroundRef = useRef(enableBackground) - if (enableBackgroundRef.current !== enableBackground) { - error('[Mpx runtime error]: background use should be stable in the component lifecycle, or you can set [enable-background] with true.') - } - const nodeRef = useRef(null) useNodesRef(props, ref, nodeRef, { style: normalStyle @@ -758,7 +757,7 @@ const _View = forwardRef, _ViewProps>((viewProps, r const childNode = wrapWithChildren(props, { hasVarDec, - enableBackground: enableBackgroundRef.current, + enableBackground, textStyle, backgroundStyle, varContext: varContextRef.current,