
Security News
Oracle Drags Its Feet in the JavaScript Trademark Dispute
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
@react-hook/hover
Advanced tools
A React hook for tracking the hover state of DOM elements in browsers where hovering is possible
npm i @react-hook/hover
A React hook for tracking the hover state of DOM elements in browsers
where hovering is possible. If the browser does not support hover states
(e.g. a phone) the isHovering
value will always be false
.
Check out the example on CodeSandbox
import * as React from 'react'
import useHover from '@react-hook/hover'
const Component = (props) => {
const target = React.useRef(null)
const isHovering = useHover(target, {enterDelay: 200, leaveDelay: 200})
return <div ref={target}>{isHovering ? 'Hovering' : 'Not hovering'}</div>
}
function useHover<T extends HTMLElement>(
target: React.RefObject<T> | T | null,
options: UseHoverOptions = {}
): boolean
Argument | Type | Required? | Description |
---|---|---|---|
target | React.RefObject | T | null | Yes | A React ref created by useRef() or an HTML element |
options | UseHoverOptions | Yes | Configuration options for the hook. See UseHoverOptions below. |
boolean
This hook returns true
if the element in ref
is in a hover state, otherwise false
. This value
is always false
on devices that don't have hover states, i.e. phones.
Property | Type | Description |
---|---|---|
enterDelay | number | Delays setting isHovering to true for this amount in ms |
leaveDelay | number | Delays setting isHovering to false for htis amount in ms |
MIT
FAQs
A React hook for tracking the hover state of DOM elements in browsers where hovering is possible
We found that @react-hook/hover demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.
Security News
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.