React Answers

How to use saved image with React?

Spread the love

To use saved image with React, we can call require with the image path to and set the returned path as the value of the src prop of the img element.

For instance, we write

<img alt="timer" src={require('./images/timer.png')} />

to add an img element with the src prop set to the path returned by calling require with the local image path.

Leave a Reply

Your email address will not be published.

If you like the content of this blog, subscribe to my email list to get exclusive articles not available to anyone else.