0

Edited: only don't work in release

I use react native version 0.60.3. Before one year make an application with local images and it works well. I update Xcode to version 11 and old code and images work well also. I try to add new images for dark mode but the image doesn't show, there isn't an error, only blank space. In code use images from js file like : "url":require("../images/page1.png").

Images are added to copy bundle resources.

I try with command : npx react-native bundle --entry-file='index.ios.js' --bundle-output='./ios/main.jsbundle' --dev=false --platform='ios' --assets-dest='./ios

and copy assets and main.jsbundle to Xcode and get the same results, before I don't have assets folder in XCode, images are been in copy bundle resources. Old images work (which are added before one year), new images don't work. Did I miss something? I don't have an error and don't know how to fix this issue.

My code:

   <CustomImage 
        width={getImgWidth} height={getImgHeight} 
        lightpath={it.url} 
        darkpath={it.urldark}
        darkmode={theme.darkmode} />

CustomImage.js

const CustomImage = (props) => {
  return (
   <View style={{ width: props.width, height: props.height }}>
  {props.darkmode ? (
    <Image
      resizeMode="contain"
      style={{ width: props.width, height: props.height }}
      source={props.darkpath}
    />
     ) : (
    <Image
      resizeMode="contain"
      style={{ width: props.width, height: props.height }}
      source={props.lightpath}
    />
  )}
  </View>
 );
 };
Ismeet
  • 419
  • 5
  • 19

1 Answers1

0

Since props.darkpath = require("../images/page1.png")
Could you try:

<Image
      resizeMode="contain"
      style={{ width: props.width, height: props.height }}
      source={`${props.darkpath}`}
    />
Akhil Nayak
  • 403
  • 4
  • 8