2021-09-13 20:41:05 +00:00
|
|
|
import React, { useContext } from 'react';
|
|
|
|
|
2022-05-27 17:27:43 +00:00
|
|
|
import Touchable from '../../Touchable';
|
|
|
|
import { CustomIcon } from '../../../CustomIcon';
|
|
|
|
import styles from '../../styles';
|
|
|
|
import { BUTTON_HIT_SLOP } from '../../utils';
|
|
|
|
import { themes } from '../../../../lib/constants';
|
|
|
|
import MessageContext from '../../Context';
|
|
|
|
import { useTheme } from '../../../../theme';
|
2021-09-13 20:41:05 +00:00
|
|
|
|
|
|
|
const MessageError = React.memo(
|
2022-04-01 21:52:38 +00:00
|
|
|
({ hasError }: { hasError: boolean }) => {
|
|
|
|
const { theme } = useTheme();
|
2022-04-11 18:01:43 +00:00
|
|
|
const { onErrorPress } = useContext(MessageContext);
|
2022-04-01 21:52:38 +00:00
|
|
|
|
2021-09-13 20:41:05 +00:00
|
|
|
if (!hasError) {
|
|
|
|
return null;
|
|
|
|
}
|
2022-04-11 18:01:43 +00:00
|
|
|
|
2021-09-13 20:41:05 +00:00
|
|
|
return (
|
2022-05-27 17:27:43 +00:00
|
|
|
<Touchable onPress={onErrorPress} style={styles.rightIcons} hitSlop={BUTTON_HIT_SLOP}>
|
2022-05-10 17:40:08 +00:00
|
|
|
<CustomIcon name='warning' color={themes[theme].dangerColor} size={16} />
|
2021-09-13 20:41:05 +00:00
|
|
|
</Touchable>
|
|
|
|
);
|
|
|
|
},
|
2022-04-01 21:52:38 +00:00
|
|
|
(prevProps, nextProps) => prevProps.hasError === nextProps.hasError
|
2021-09-13 20:41:05 +00:00
|
|
|
);
|
|
|
|
|
|
|
|
MessageError.displayName = 'MessageError';
|
|
|
|
|
|
|
|
export default MessageError;
|