0

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.

  • Posible duplicate of https://stackoverflow.com/questions/30854232/react-native-image-require-module-using-dynamic-names – Charlie Nov 28 '19 at 17:05
  • the svg module uses require ('source / path'), the problem does not apply to this link solution,but thanks so far to get around the problem I had to use react-native's native image. But I needed to use react-native-svg's native Image – Andersonfrfilho Dec 02 '19 at 14:12

1 Answers1

0

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