@practical-react-hooks/use-click

1.0.0 • Public • Published

@practical-react-hooks/use-click

React Hook to detect and execute the function when someone click the element.

Installation

yarn

yarn add @practical-react-hooks/use-click

npm

npm i @practical-react-hooks/use-click

Usage

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

const App = () => {
  const sayHello = () => console.log("Hello World!");
  const trigger = useClick(sayHello)
  return (
    <div className="App">
      <h1 ref={trigger}>Hello</h1>
    </div>
  );
};

Arguments

Argument Type Description Required
onClick function The function to execute when click element yes

Dependencies (0)

    Dev Dependencies (0)

      Package Sidebar

      Install

      npm i @practical-react-hooks/use-click

      Weekly Downloads

      0

      Version

      1.0.0

      License

      MIT

      Unpacked Size

      2.11 kB

      Total Files

      4

      Last publish

      Collaborators

      • octo908