@doiali/use-hover
TypeScript icon, indicating that this package has built-in type declarations

1.0.2 • Public • Published

react-use-hover

a hook that returns a hover state and a ref, pass the ref to a component, then the hover state becomes true when the mouse is hovering that component

Installation

npm install @doiali/use-hover

Usage

import React from 'react';
import useHover from '@doiali/use-hover';

export default function SayHello() {
    const [isHovering,ref] = useHover();
    const style = {
        height:80,
        width:150,
        textAlign: "center",
        margin:'auto',
        border:`1px solid black`,
    }

    return (
        <div ref={ref} style={style}>
            hover me! <br/>
            {isHovering && "Hello!"}
        </div>
    )
}

Dependencies (0)

    Dev Dependencies (9)

    Package Sidebar

    Install

    npm i @doiali/use-hover

    Weekly Downloads

    7

    Version

    1.0.2

    License

    ISC

    Unpacked Size

    4.44 kB

    Total Files

    5

    Last publish

    Collaborators

    • doiali