Rob Indesteege
Rob Indesteege

Reputation: 558

Importing images at run-time

What is the (best) way to import images at runtime in Create-react-app. My app fetches an array from an API containing ~20 image names. How do I load these images into my app on run-time to display them? (there are over 300 images in the image folder, so importing/bundling them all is not a good option).

Upvotes: 0

Views: 82

Answers (1)

J.B
J.B

Reputation: 60

If you are hosting a lot of images, I would look at maybe creating a CDN or even just put them in an S3 bucket on AWS. This would reduce load on your website. The image names can be mapped to the names in the S3 bucket as long as they're named the same.

Upvotes: 1

Related Questions