Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Image React-native not working

Iam trying to do this:

<Image
  style={styles.image}
  source={require(`./img/${params.image}.png`)}
/>

but returns me this error: "Unknown named moduleenter image description here"

like image 410
Luiz Fernando Sousa Camargo Avatar asked Nov 29 '25 01:11

Luiz Fernando Sousa Camargo


1 Answers

I have also faced this issue, you can not call image like

source={require(`./img/${params.image}.png`)}

you have to use another variable to store path and then call it (including require)

For example:

let imagePath = require("../../assets/list.png");

Also note that you can not call variable into require.

check this ref. url: https://github.com/facebook/react-native/issues/2481

like image 88
Jigar Shah Avatar answered Dec 02 '25 05:12

Jigar Shah