Get Even More Visitors To Your Blog, Upgrade To A Business Listing >>

How to display images in React using JSX without import?

Sometimes, we want to display images in React using JSX without Import.

In this article, we’ll look at how to display images in React using JSX without import.

How to display images in React using JSX without import?

To display images in React using JSX without import, we use require.

For instance, we write

const imageName = require("./images/image1.jpg");

//...

const Comp = () => {
  //...
  return ;
};

to call require with the image path to import the image path.

Then we can use that as the value of the src property to load the image.

Conclusion

To display images in React using JSX without import, we use require.

The post How to display images in React using JSX without import? appeared first on The Web Dev.



This post first appeared on The Web Dev, please read the originial post: here

Share the post

How to display images in React using JSX without import?

×

Subscribe to The Web Dev

Get updates delivered right to your inbox!

Thank you for your subscription

×