How to load image file inline in MERN Stack Application

Viewed 99

I'm trying to load image from file inline cuz I have to pass data (the image name) but nothing works, nor if the image is inside src folder, nor if it's outside in public folder

Here is what I tried last:

<img src={require(`./styles/images/${image}`).default} alt="product img" />

the server returns:

Error: No default engine was specified and no extension was provided.

1 Answers

You can use something like this

import logo from './logo.png';

<img src={logo} alt="logo" />
Related