Created
September 19, 2019 01:13
-
-
Save anderjs/c7cdba599d7e965d3c326c374dc13fb9 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React, { memo } from 'react' | |
import PropTypes from 'prop-types' | |
import Happy from '../../assets/img/happy.png' | |
const Emoji = ({ type }) => { | |
const icons = new Map([ | |
['happy', { src: Image, width: 300, height: 300, className: '' }], | |
['sad', { src: '', width: 0, height: 300, className: ''] | |
]) | |
return ( | |
<img src={icons.get(type).src} alt='emoji' width={icons.get(type).width} /> | |
) | |
} | |
Emoji.defaultProps = { | |
width: 300, | |
height: 100 | |
} | |
Emoji.propTypes = { | |
type: PropTypes.oneOf(['happy', 'sad']).isRequired | |
} | |
export default memo(Emoji) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment