Search code examples
react-nativereact-native-svg

Importing Different Images into the Image Component react-native-svg


Question

Guys, since I am already having problems importing image I need to show different images in each mode, but when trying

<Image
   href={require(`../../../assets/images/questions/${imageName}.png`)}//eslint-disable-line
/>

an error is returned

Loading dependency graph, done.
error: bundling failed: src\components\OptionImage\index.js: src\components\OptionImage\index.js:Invalid call at line 39: require("../../../assets/images/questions/" + imageName + ".png")

trying

<Image
    href={require('../../../assets/images/questions/'+imageName+'.png')}
/>

an error is returned

Loading dependency graph, done.
error: bundling failed: src\components\OptionImage\index.js: src\components\OptionImage\index.js:Invalid call at line 38: require('../../../assets/images/questions/' + imageName + '.png')

using

          <Photo
            href={require('../../../assets/images/questions/default.png')}//eslint-disable-line
          />

works but gets static image I can't change

could anyone help thank you.


Solution

  • I found the answer to this problem here. thank you all https://github.com/react-native-community/react-native-svg/issues/1204