1.0.7 • Published 2 years ago

@jaegeun/use-command v1.0.7

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

@jaegeun/use-command

React Hook for command Action

Installation

yarn

yarn add @jaegeun/use-command

npm

npm i @jaegeun/use-command

Usage

import React from "react";
import useCommand from "@jaegeun/use-command";

function App() {
  const doOnEvery = () => console.log("This is Everywhere!");
  const arrowUp = () => console.log("I'm ArrayUp");
  const arrowDown = () => console.log("I'm ArrayDown");
  const arrowLeft = () => console.log("I'm ArrayLeft");
  const arrowRight = () => console.log("I'm ArrayRight");
  const enter = () => console.log("I'm Entered");
  const escape = () => console.log("I'm Escape");
  const {elemnet, onChange} = useCommand(doOnEvery,arrowUp,arrowDown,arrowLeft,arrowRight,enter,escape);
  return <input ref={element} onKeyDown={onChange}>Hello Nooks</h1>;
}

Arguments

ArgumentTypeDescriptionRequired
doOnEveryfunctionFunction to be called when the element is hoveredno
arrowUpfunctionFunction to be called when the element is hoveredno
arrowDownfunctionFunction to be called when the element is hoveredno
arrowLeftfunctionFunction to be called when the element is hoveredno
arrowRightfunctionFunction to be called when the element is hoveredno
enterfunctionFunction to be called when the element is hoveredno
escapefunctionFunction to be called when the element is hoveredno

Return

Return valueTypeDescriptionDefault value
refReact RefA React Ref listening to the onKeyDown event, add it to any elementnull
handlerfunctiononKeyDown Event Handlernull
1.0.7

2 years ago

1.0.6

2 years ago

1.0.5

2 years ago

1.0.4

2 years ago

1.0.3

2 years ago

1.0.2

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago