diff options
author | dan <dan.abramov@gmail.com> | 2023-09-08 00:38:57 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-09-07 16:38:57 -0700 |
commit | a5b89dffa6713bb06c1c572bbdc00517cf5e9bc5 (patch) | |
tree | ac8aa2deec7cc24d9a3553bab0c48335d2e8677c /src/view/com/util/PressableWithHover.tsx | |
parent | 00595591c46db6ebfa9a8ee404f275b43493f7e0 (diff) | |
download | voidsky-a5b89dffa6713bb06c1c572bbdc00517cf5e9bc5.tar.zst |
Add ESLint React plugin (#1412)
* Add eslint-plugin-react * Enable display name rule
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> + ) +}) |