Italo Rodrigo
Italo Rodrigo

Reputation: 1785

Error on set argument to Image

{this.state.items.map((item) => (
  <View style={{height:10, padding:10}}>
    <Image
      style={{flex:1, width: null, height: null, borderRadius:10}}
      source={require(`${item.imagem}`)}
    />
  </View>
  )
)}

I cant to set the source > require > argument using a data map

bundling failed: Error: calls to require expect exactly 1 string literal argument, but this was found: require("" + item.codigo).

Upvotes: 0

Views: 76

Answers (1)

Rafael Motta
Rafael Motta

Reputation: 2537

This is not possible.

You should generate a massive switch-case statement to require what you want or use a babel plugin

You can check more details here:

Upvotes: 1

Related Questions