1.0.0 • Published 4 years ago

@ej-hooks/use-input v1.0.0

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

@ej-hooks/use-input

React Hook to update input with validator.

Installation

yarn

yarn add @ej-hooks/use-input

npm

npm i @ej-hooks/use-input

Usage

import React from 'react';
import useInput from '@ej-hooks/use-input';
function App() {
  const maxLen = (value) => value.length <= 10;
  //const noAt = (value) => !value.includes('@');
  const name = useInput('Mr.', maxLen);
  return <input placeholder="Name" {...name} />;
}

Arguments

ArgumentTypeDescriptionRequired
initialValuestringInitial input valueyes
validatorfunctionFunction to validate the input valueno