1.0.1 • Published 2 years ago

verify-code-input-react v1.0.1

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

verify-code-input-react

React component to insert a code (number, text, password) in a sigle input elements

verify-code

NPM JavaScript Style Guide

Install

npm i verify-code-input-react

or

yarn add verify-code-input-react

or

pnpm i verify-code-input-react

Usage

1 . Require verify-code-input-react after installation

import { InputCode } from 'verify-code-input-react';

2 . Include verify-code-input-react as in the following example

use ref

import React, { useRef } from 'react';
import { InputCode } from 'verify-code-input-react';

const App = () => {
  const ref = useRef('');

  const handleClick = () => {
    console.log(ref.current.value);
  };

  return (
    <>
      <InputCode ref={ref} fields={6} placeholder='-' type='text' placeholder={'-'} />
      <button onClick={handleClick}>submit</button>
    </>
  );
};

use onTriggerChange function

import React, { useState } from 'react';
import { InputCode } from 'verify-code-input-react';

const App = () => {
  const [value, setValue] = useState<string>('');

  const handleClick = () => {
    console.log(value);
  };

  return (
    <>
      <InputCode
        fields={6}
        onKeyDownInput={() => {}}
        onTriggerChange={setValue}
        placeholder='-'
        type='text'
        placeholder={'-'}
      />
      <button onClick={handleClick}>submit</button>
    </>
  );
};

Props

Contributors

MIT © StanTran

1.0.1

2 years ago

0.1.10

2 years ago

0.1.9

2 years ago

0.1.8

2 years ago

0.1.7

2 years ago

0.1.6

2 years ago

0.1.5

2 years ago

0.1.4

2 years ago

0.1.3

2 years ago

0.1.2

2 years ago

0.1.1

2 years ago

0.1.0

2 years ago