0
Good evening I have a js file with an array of objects and one of these properties is image as I do to render it in src already tried {item.image} but it’s just a string and React apparently uses images as if they were components, another detail is that the image property of these objects receives a string that is the location of these images .. /Assets/imageTal.png, it does not render at all or searches at least
Looks like it might work, thanks
– Gabriel Crevelario
You can use require in the array or even import the images and put the import type name:
import { nome_que_vc_quiser } from './assets/sua_imagem.jpg';
and ai in the Voce array uses the name you placed in the image.– Carlos Querioz
po ta not working, look what I wrote
– Gabriel Crevelario
<ul> { items.map(item => ( <li key={item.id}> <button onClick=this.handlerClick.bind(this,item)}> <div classname="containerImage"> <img src={require(
${item.image}
)} alt="test"/> </button> </li> ))} ) </ul>– Gabriel Crevelario
Sort your array where the image is. It will be easier to understand.
– Carlos Querioz
I managed to settle the way you said thanks so I marked it as settled!
– Gabriel Crevelario
Show! Anything calls there.
– Carlos Querioz
Of course! Thank you
– Gabriel Crevelario