Skip to content

Commit 1e47873

Browse files
committed
feat: 调整三目运算符格式
1 parent 5cbf1ed commit 1e47873

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

packages/webpack-plugin/lib/runtime/components/react/mpx-async-suspense.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ const DefaultFallback = ({ onReload }: DefaultFallbackProps) => {
8383
const DefaultLoading = () => {
8484
// eslint-disable-next-line @typescript-eslint/no-var-requires
8585
const FastImageModule = require('@d11/react-native-fast-image')
86-
const FastImage = FastImageModule && FastImageModule.default ? FastImageModule.default : FastImageModule
86+
const FastImage = FastImageModule.default || FastImageModule
8787
return (
8888
<View style={styles.container}>
8989
<FastImage

packages/webpack-plugin/lib/runtime/components/react/utils.tsx

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -757,10 +757,12 @@ export function renderImage (
757757
imageProps: ImageProps | FastImageProps,
758758
enableFastImage = false
759759
) {
760-
// eslint-disable-next-line @typescript-eslint/no-var-requires
761-
const FastImageModule = enableFastImage ? require('@d11/react-native-fast-image') : null
762-
const FastImage = FastImageModule && FastImageModule.default ? FastImageModule.default : FastImageModule
763-
const Component: React.ComponentType<ImageProps | FastImageProps> = enableFastImage && FastImage ? FastImage : Image
760+
let Component: React.ComponentType<ImageProps | FastImageProps> = Image
761+
if (enableFastImage) {
762+
// eslint-disable-next-line @typescript-eslint/no-var-requires
763+
const fastImageModule = require('@d11/react-native-fast-image')
764+
Component = fastImageModule.default || fastImageModule
765+
}
764766
return createElement(Component, imageProps)
765767
}
766768

0 commit comments

Comments
 (0)