-1

I get 500 error while using dynamic resource to display an image. <Image style={styles.image} source={require('../component/images/react-native.png')} /> <Image style={styles.image} source={require(article.imageUrl)} />

"article.imageUrl" has exactly same value as first text.

react: 16.6.3

react-native: 0.58.4

bahar.alirezaei
  • 87
  • 3
  • 11

1 Answers1

1

Instead of article.imageUrl="../component/images/react-native.png" , change it to:

article.imageUrl=require("../component/images/react-native.png");

and then:

source={article.imageUrl}

Because as Andrew commented, you can't use dynamic variales with require.

angelos_lex
  • 1,593
  • 16
  • 24