Skip to content

Instantly share code, notes, and snippets.

@anderjs
Created September 19, 2019 01:13
Show Gist options
  • Save anderjs/c7cdba599d7e965d3c326c374dc13fb9 to your computer and use it in GitHub Desktop.
Save anderjs/c7cdba599d7e965d3c326c374dc13fb9 to your computer and use it in GitHub Desktop.
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