@gitgw/use-hover

1.0.2 • Public • Published

@gitgw/use-hover

React Hook to detect a hover on an any React Element.

Installation

npm

npm i @gitgw/use-hover

yarn

yarn add @gitgw/use-hover

Usage

import React from "react";
import useHover from "@gitgw/use-hover";

function App() {

  const onHover = ()=>{
    console.log("OnHover");
  }

  const markedRef = useHover(onHover);
  
  return (
    <div className="App">
      <div ref={markedRef}>Hello</div>
    </div>
  );
}

Arguments

Argument Type Description Required
onHover Function Function to be called when the element is hovered yes

Return

Return value Type Description Default value
ref React ref A React ref listening to the hover event, add it to any element null

Package Sidebar

Install

npm i @gitgw/use-hover

Weekly Downloads

1

Version

1.0.2

License

MIT

Unpacked Size

1.98 kB

Total Files

4

Last publish

Collaborators

  • githubgw