Created
August 9, 2021 09:17
-
-
Save morajabi/cb58d52fa26477a026dd09c61e725c5f to your computer and use it in GitHub Desktop.
Use Hover for react native web
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { useMemo } from 'react' | |
import { useState } from 'react' | |
export function useHover() { | |
const [hovered, setHovered] = useState(false) | |
let callbacks = useMemo( | |
() => ({ | |
onMouseEnter: () => { | |
setHovered(true) | |
}, | |
onMouseLeave: () => { | |
setHovered(false) | |
}, | |
}), | |
[], | |
) | |
return [hovered, callbacks] | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment