Yollo
Yollo

Reputation: 89

How to load image file inline in MERN Stack Application

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.

Upvotes: 1

Views: 233

Answers (1)

onkar.v
onkar.v

Reputation: 135

You can use something like this

import logo from './logo.png';

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

Upvotes: 1

Related Questions