vn-verdnaturachat/app/containers/message/Emoji.js

29 lines
887 B
JavaScript
Raw Normal View History

2020-05-04 14:09:47 +00:00
import React from 'react';
import { Text } from 'react-native';
import PropTypes from 'prop-types';
import shortnameToUnicode from '../../utils/shortnameToUnicode';
import CustomEmoji from '../EmojiPicker/CustomEmoji';
const Emoji = React.memo(({
2020-05-04 14:09:47 +00:00
content, baseUrl, standardEmojiStyle, customEmojiStyle, getCustomEmoji
}) => {
const parsedContent = content.replace(/^:|:$/g, '');
const emoji = getCustomEmoji(parsedContent);
if (emoji) {
return <CustomEmoji key={content} baseUrl={baseUrl} style={customEmojiStyle} emoji={emoji} />;
}
return <Text style={standardEmojiStyle}>{ shortnameToUnicode(content) }</Text>;
}, () => true);
Emoji.propTypes = {
content: PropTypes.string,
2020-05-04 14:09:47 +00:00
baseUrl: PropTypes.string,
standardEmojiStyle: PropTypes.object,
customEmojiStyle: PropTypes.object,
getCustomEmoji: PropTypes.func
};
Emoji.displayName = 'MessageEmoji';
export default Emoji;