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

30 lines
940 B
JavaScript
Raw Normal View History

import React, { useContext } from 'react';
import PropTypes from 'prop-types';
import Touchable from './Touchable';
import { CustomIcon } from '../../lib/Icons';
import styles from './styles';
import { BUTTON_HIT_SLOP } from './utils';
2019-12-04 16:39:53 +00:00
import { themes } from '../../constants/colors';
import MessageContext from './Context';
const MessageError = React.memo(({ hasError, theme }) => {
if (!hasError) {
return null;
}
const { onErrorPress } = useContext(MessageContext);
return (
<Touchable onPress={onErrorPress} style={styles.errorButton} hitSlop={BUTTON_HIT_SLOP}>
2019-12-04 16:39:53 +00:00
<CustomIcon name='warning' color={themes[theme].dangerColor} size={18} />
</Touchable>
);
2019-12-04 16:39:53 +00:00
}, (prevProps, nextProps) => prevProps.hasError === nextProps.hasError && prevProps.theme === nextProps.theme);
MessageError.propTypes = {
hasError: PropTypes.bool,
2019-12-04 16:39:53 +00:00
theme: PropTypes.string
};
MessageError.displayName = 'MessageError';
export default MessageError;