1.0.6 • Published 3 years ago

@gitgw/use-input v1.0.6

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

@gitgw/use-input

React Hook that checks the length of the input.

Installation

npm

npm i @gitgw/use-input

yarn

yarn add @gitgw/use-input

Usage

import React from "react";
import useInput from "@gitgw/use-input";

function App() {

  const checkIdLength = (value) => {
    return value.length < 5;
  }
  const checkPasswordLength = (value) => {
    return value.length < 10;
  }

  const inputId = useInput("", checkIdLength);
  const inputPassword = useInput("", checkPasswordLength);
  
  return (
    <div className="App">
      <input type="text" placeholder="ID" {...inputId}/>
      <input type="password" placeholder="Password" {...inputPassword}/>
    </div>
  );
}

Arguments

ArgumentTypeDescriptionRequired
valueStringThe value you want to use on your inputyes
checkLengthFunctionFunction used to check input lengthyes

Return

Return valueTypeDescriptionDefault value
ObjectObjectAn object containing input values and checkLength function{value:"", onChange: f}
1.0.6

3 years ago

1.0.5

3 years ago

1.0.4

3 years ago

1.0.3

3 years ago

1.0.2

3 years ago

1.0.1

3 years ago

1.0.0

3 years ago