From 9ca18433ffad66fe1d813eb704e99854a6c6c6e5 Mon Sep 17 00:00:00 2001 From: Sean Yesmunt Date: Tue, 2 Jul 2019 00:39:17 -0400 Subject: [PATCH] consistent language with follow/unfollow --- src/ui/component/subscribeButton/view.jsx | 21 +++------------------ src/ui/page/tags/view.jsx | 17 +++++++++-------- src/ui/util/use-hover.js | 23 +++++++++++++++++++++++ 3 files changed, 35 insertions(+), 26 deletions(-) create mode 100644 src/ui/util/use-hover.js diff --git a/src/ui/component/subscribeButton/view.jsx b/src/ui/component/subscribeButton/view.jsx index e9c0b266d..cdaea453a 100644 --- a/src/ui/component/subscribeButton/view.jsx +++ b/src/ui/component/subscribeButton/view.jsx @@ -1,9 +1,10 @@ // @flow import * as MODALS from 'constants/modal_types'; import * as ICONS from 'constants/icons'; -import React, { useState, useRef, useEffect } from 'react'; +import React, { useRef } from 'react'; import { parseURI } from 'lbry-redux'; import Button from 'component/button'; +import useHover from 'util/use-hover'; type SubscribtionArgs = { channelName: string, @@ -33,28 +34,12 @@ export default function SubscribeButton(props: Props) { doToast, } = props; const buttonRef = useRef(); - const [isHovering, setIsHovering] = useState(false); + const isHovering = useHover(buttonRef); const { claimName } = parseURI(uri); const subscriptionHandler = isSubscribed ? doChannelUnsubscribe : doChannelSubscribe; const subscriptionLabel = isSubscribed ? __('Following') : __('Follow'); const unfollowOverride = isSubscribed && isHovering && __('Unfollow'); - useEffect(() => { - function handleHover() { - setIsHovering(!isHovering); - } - - const button = buttonRef.current; - if (button) { - button.addEventListener('mouseover', handleHover); - button.addEventListener('mouseleave', handleHover); - return () => { - button.removeEventListener('mouseover', handleHover); - button.removeEventListener('mouseleave', handleHover); - }; - } - }, [buttonRef, isHovering]); - return (