1.1.6 • Published 2 years ago

@generalizers/react-events v1.1.6

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

@generalizers/react-events

Author : Alan BLANCHET

Installation

NPM

npm i @generalizers/react-events

SSH

npm i git+https://github.com/Generalizers/react-events.git

Hooks

useKey

The useKey hook is used to attach a key event on the document and detach it whenever the component is unmounted. It is updated based on the dependency list to add optimization.

Parameters

parametertypedescription
type"down", "up", "pressed"The type of the key
f() => voidThe function to be called and removed on mount / unmount / update
dependency listany[], undefinedThe react watch list that uses useEffect under the hood

useMouse

The useMouse hook is used to attach a mouse event on the document and detach it whenever the component is unmounted. It is updated based on the dependency list to add optimization.

It is useful whenever you want to do an action if a user clicks outside of a specific inner box (not on the document). You can use e.stopPropagation() on this box to prevent the event to rise up to the document event.

Parameters

parametertypedescription
type"click", "down", "enter", "leave", "move","out","over", "up"The type of the mouse event
f() => voidThe function to be called and removed on mount / unmount / update
dependency listany[], undefinedThe react watch list that uses useEffect under the hood

useContextMenu

The useContextMenu hook function is called whenever the user right clicks and the browser menu pops up. You can override this feature and use the hook to manage states in react.

useEvent

For a more general use. You can use the useEvent hook to create your custom hooks based on the document events

1.1.1

2 years ago

1.1.0

2 years ago

1.1.6

2 years ago

1.1.5

2 years ago

1.0.6

2 years ago

1.1.4

2 years ago

1.0.5

2 years ago

1.1.3

2 years ago

1.0.4

2 years ago

1.1.2

2 years ago

1.0.3

2 years ago

1.0.2

2 years ago

1.0.1

2 years ago

1.0.0

3 years ago