Skip to content

Commit

Permalink
fix(*): fix backgroud style.
Browse files Browse the repository at this point in the history
  • Loading branch information
shangqunfeng committed Dec 24, 2024
1 parent 3d599d0 commit 7834e70
Showing 1 changed file with 7 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -643,7 +643,7 @@ function wrapImage (imageStyle?: ExtendedViewStyle, innerStyle?: Record<string,

interface WrapChildrenConfig {
hasVarDec: boolean
enableBackground: boolean
enableBackground?: boolean
textStyle?: TextStyle
backgroundStyle?: ExtendedViewStyle
varContext?: Record<string, any>
Expand All @@ -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,
Expand Down Expand Up @@ -715,12 +720,6 @@ const _View = forwardRef<HandlerRef<View, _ViewProps>, _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<View, _ViewProps>(props, ref, nodeRef, {
style: normalStyle
Expand Down Expand Up @@ -758,7 +757,7 @@ const _View = forwardRef<HandlerRef<View, _ViewProps>, _ViewProps>((viewProps, r

const childNode = wrapWithChildren(props, {
hasVarDec,
enableBackground: enableBackgroundRef.current,
enableBackground,
textStyle,
backgroundStyle,
varContext: varContextRef.current,
Expand Down

0 comments on commit 7834e70

Please sign in to comment.