diff options
Diffstat (limited to 'src/view/com/util/PressableWithHover.tsx')
-rw-r--r-- | src/view/com/util/PressableWithHover.tsx | 56 |
1 files changed, 27 insertions, 29 deletions
diff --git a/src/view/com/util/PressableWithHover.tsx b/src/view/com/util/PressableWithHover.tsx index 09ccb6a2d..77276f184 100644 --- a/src/view/com/util/PressableWithHover.tsx +++ b/src/view/com/util/PressableWithHover.tsx @@ -12,34 +12,32 @@ interface PressableWithHover extends PressableProps { hoverStyle: StyleProp<ViewStyle> } -export const PressableWithHover = forwardRef( - ( - { - children, - style, - hoverStyle, - ...props - }: PropsWithChildren<PressableWithHover>, - ref: Ref<any>, - ) => { - const [isHovering, setIsHovering] = useState(false) +export const PressableWithHover = forwardRef(function PressableWithHoverImpl( + { + children, + style, + hoverStyle, + ...props + }: PropsWithChildren<PressableWithHover>, + ref: Ref<any>, +) { + const [isHovering, setIsHovering] = useState(false) - const onHoverIn = useCallback(() => setIsHovering(true), [setIsHovering]) - const onHoverOut = useCallback(() => setIsHovering(false), [setIsHovering]) - style = - typeof style !== 'function' && isHovering - ? addStyle(style, hoverStyle) - : style + const onHoverIn = useCallback(() => setIsHovering(true), [setIsHovering]) + const onHoverOut = useCallback(() => setIsHovering(false), [setIsHovering]) + style = + typeof style !== 'function' && isHovering + ? addStyle(style, hoverStyle) + : style - return ( - <Pressable - {...props} - style={style} - onHoverIn={onHoverIn} - onHoverOut={onHoverOut} - ref={ref}> - {children} - </Pressable> - ) - }, -) + return ( + <Pressable + {...props} + style={style} + onHoverIn={onHoverIn} + onHoverOut={onHoverOut} + ref={ref}> + {children} + </Pressable> + ) +}) |