Make parent Emoji component a functional component

Just like NimbleEmoji.

Read more: https://medium.com/missive-app/45-faster-react-functional-components-now-3509a668e69f
release
Etienne Lemay 2018-04-26 11:16:21 -04:00
parent 8660a146e2
commit d17594315c
No known key found for this signature in database
GPG Key ID: EE7CF89146BB28E9
1 changed files with 9 additions and 3 deletions

View File

@ -3,11 +3,17 @@ import data from '../data'
import { EmojiPropTypes, EmojiDefaultProps } from '../utils/shared-props'
import NimbleEmoji from './emoji'
export default class Emoji extends React.PureComponent {
render() {
return <NimbleEmoji {...this.props} {...this.state} />
const Emoji = (props) => {
for (let k in Emoji.defaultProps) {
if (props[k] == undefined && Emoji.defaultProps[k] != undefined) {
props[k] = Emoji.defaultProps[k]
}
}
return NimbleEmoji({ ...props })
}
Emoji.propTypes = EmojiPropTypes
Emoji.defaultProps = { ...EmojiDefaultProps, data }
export default Emoji