@smooks/use-click
v1.0.0
Published
React Hook to detect click of element.
Downloads
2
Readme
@smooks/use-click
React Hook to detect click of element.
Installation
yarn
yarn add @smooks/use-click
npm
npm i @smooks/use-click
Usage
import useClick from '@smooks/use-click';
const Click = () => {
const sayHello = () => alert("Element was clicked!");
const title = useClick(sayHello);
return (
<>
<div className="App">
<h1 ref={title}>Hello</h1>
</div>
<Link to="/"><button>go to home</button></Link>
</>
);
};
Argument
| Argument | Type | Description | Required | | -------- | -------- | -------- | -------- | | onClick | function | A function that start when click event is happened. | yes |