Meybinson Yánez
Meybinson Yánez

Reputation: 13

How to use image src dynamically

I am trying to import images that are in the src folder but vs code tells me that the names of the files that I am importing are not being used in the code. Does anyone know why?

import

I want the images to be displayed in the carousel without any problem.

Upvotes: 1

Views: 2675

Answers (2)

Sudip Shrestha
Sudip Shrestha

Reputation: 432

You should remove the extra quote for src

<img src={atlus} />

Upvotes: 0

Scott Mitchell
Scott Mitchell

Reputation: 212

I can see that Ashraful Mijan already answered above. I just thought that I would add something. Instead of importing them from your src folder, you could put them in your public folder then you would not need to import them and could just set the path directly in the img tag.

For example, if you have your images stored in public/assets, then you could just do this in your carousel.

<img src="/assets/image1.jpg" />

Upvotes: 1

Related Questions