Image now showing up on screen while using Material UI <Image> props

Viewed 36

I installed and imported mui-image into my React project and used it as a component <Image>. The issue is my png image did not showed up on screen (neither svg). However, I inserted a random image link on the internet and it worked. Does that mean my the issue is from my png image? And how do I fix this bug?

I installed npm i mui-imagethen imported import { Image } from "mui-image" to my index.js file

then imported my png image as import { mypng } from "../img/mypng.png";

...<Image src={mypng} /> (mypng has the dimension of: 2880 × 800)

However, it worked with a random url: <Image src="https://source.unsplash.com/200x200" />

I would really appreciate your help!

1 Answers

You're using object deconstruction in your import. "../img/mypng.png" has no property called mypng. Try :

import mypng from "../img/mypng.png";
Related