Why Image is not showing in the browser in Material-UI Avatar component?

Viewed 4597

I am using Material-UI Avatar React component to show profile images. While compiling it can reach the image, there is no error in compile time. But image is not showing in the browser.

Please check this image to better understand

Codes:

import {avatar} from '../../images/avatar.png';

<Box component='div'>
     <Avatar src={avatar} alt="Russel Crow"/>
</Box>

Please tell me why image is not showing in the browser and How to show it?

2 Answers

You used a named import, try it like this:

import avatar from '../../images/avatar.png'

You can try with inline url.

Try to run like this

import Avatar from '@material-ui/core/Avatar';

   <Avatar alt="Remy Sharp" src="/static/images/avatar/1.jpg" />
Related