@feca-hooks/use-event

1.0.1 • Public • Published

@feca-hooks/use-event

React Hook to add event on element or component faster and easier.


How to Install

yarn

yarn add @feca-hooks/use-event

npm

npm i @feca-hooks/use-event


Usage

Code

import React from "react";
import useEvent from "@feca-hooks/use-event";

function App() {
  const onMouseEnter = (event) => {
    console.log(event.target);
  }

  const eventRef = useEvent("mouseEnter", onMouseEnter);

  return <div ref={eventRef}>Hover Me!</div>;
}

Arguments

Argument Type Description Required
eventType string The any vaild event type of event listener. yes
onEvent function The callback function executes when the event occured. yes

Return

Return value Type Description
Ref of element object(ref) You can apply custom event setting property ref using this.

Dependents (0)

Package Sidebar

Install

npm i @feca-hooks/use-event

Weekly Downloads

1

Version

1.0.1

License

MIT

Unpacked Size

2.59 kB

Total Files

4

Last publish

Collaborators

  • pshtony1