1.0.1 • Published 3 years ago

@feca-hooks/use-event v1.0.1

Weekly downloads
-
License
MIT
Repository
github
Last release
3 years ago

@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

ArgumentTypeDescriptionRequired
eventTypestringThe any vaild event type of event listener.yes
onEventfunctionThe callback function executes when the event occured.yes

Return

Return valueTypeDescription
Ref of elementobject(ref)You can apply custom event setting property ref using this.
1.0.1

3 years ago

1.0.0

3 years ago