diff --git a/src/components/EmojiPicker/CategoryShortcutButton.js b/src/components/EmojiPicker/CategoryShortcutButton.js index c414e7c1aae2..a7658ae0542d 100644 --- a/src/components/EmojiPicker/CategoryShortcutButton.js +++ b/src/components/EmojiPicker/CategoryShortcutButton.js @@ -1,8 +1,8 @@ -import React, {PureComponent} from 'react'; +import React, {useState} from 'react'; import PropTypes from 'prop-types'; import Icon from '../Icon'; import Tooltip from '../Tooltip'; -import withLocalize, {withLocalizePropTypes} from '../withLocalize'; +import useLocalize from '../../hooks/useLocalize'; import variables from '../../styles/variables'; import styles from '../../styles/styles'; import * as StyleUtils from '../../styles/StyleUtils'; @@ -20,48 +20,36 @@ const propTypes = { /** The function to call when an emoji is selected */ onPress: PropTypes.func.isRequired, - - ...withLocalizePropTypes, }; -class CategoryShortcutButton extends PureComponent { - constructor(props) { - super(props); - this.state = { - isHighlighted: false, - }; - } +function CategoryShortcutButton(props) { + const {translate} = useLocalize(); + const [isHighlighted, setIsHighlighted] = useState(false); - render() { - return ( - + setIsHighlighted(true)} + onHoverOut={() => setIsHighlighted(false)} + style={({pressed}) => [StyleUtils.getButtonBackgroundColorStyle(getButtonState(false, pressed)), styles.categoryShortcutButton, isHighlighted && styles.emojiItemHighlighted]} + accessibilityLabel={`emojiPicker.headers.${props.code}`} + accessibilityRole={CONST.ACCESSIBILITY_ROLE.BUTTON} > - this.setState({isHighlighted: true})} - onHoverOut={() => this.setState({isHighlighted: false})} - style={({pressed}) => [ - StyleUtils.getButtonBackgroundColorStyle(getButtonState(false, pressed)), - styles.categoryShortcutButton, - this.state.isHighlighted && styles.emojiItemHighlighted, - ]} - accessibilityLabel={`emojiPicker.headers.${this.props.code}`} - accessibilityRole={CONST.ACCESSIBILITY_ROLE.BUTTON} - > - - - - ); - } + + + + ); } CategoryShortcutButton.propTypes = propTypes; - -export default withLocalize(CategoryShortcutButton); +CategoryShortcutButton.displayName = 'CategoryShortcutButton'; +export default React.memo(CategoryShortcutButton);