npm.io
1.0.3 • Published 5 years ago

@jacob-hooks/use-click

Licence
MIT
Version
1.0.3
Deps
0
Size
4 kB
Vulns
0
Weekly
0

@jacob-hooks/use-click

React Hook to execute a function when the mouse click then add event listener

installation

yarn

yarn add @jacob-hooks/use-click

npm

npm i @jacob-hooks/use-click

Usage

import React from "react";
import useClick from "@jacob-hooks/use-click";

const App = () => {
  const sayHello = () => console.log("Say Hello");

  const title = useClick(sayHello);

  return (
    <div className="App">
      <h1 ref={title}>Hello</h1>
    </div>
  );
};
Arguments
Argument Type Description Required
click string The mouse click then add event lister yes

Keywords