-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathindex.js
More file actions
29 lines (22 loc) · 789 Bytes
/
index.js
File metadata and controls
29 lines (22 loc) · 789 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
/**
* This component represents a sample image component for application
*/
import React, { useEffect, useState } from 'react';
import PropTypes from 'prop-types';
import DefaultImage from '../../assets/images/profile.png';
import './index.scss';
const CustomImage = (props) => {
const [image, setImage] = useState("")
useEffect(() => {
setImage(props.image || DefaultImage)
}, [props.image])
const classNames = `litnite-image ${props.className && props.className}`;
const { width = 50, height = 50 } = props;
return <img className={classNames} src={image} width={width} height={50} onError={() => setState({ image: DefaultImage })} />
}
CustomImage.propTypes = {
width: PropTypes.number,
height: PropTypes.number,
radius: PropTypes.number
}
export default CustomImage;