# react-native-headless-code-input

> A headless hook to handle verification code input.

Latest version **1.0.7** (published 2021-03-10) · MIT license · 0 weekly downloads

## Install

```sh
npm install react-native-headless-code-input
pnpm add react-native-headless-code-input
yarn add react-native-headless-code-input
bun add react-native-headless-code-input
```

## Health

**Score 20/100 (F)** — status: abandoned.

Positive: has types; no vulnerabilities.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.7 |
| Published | 2021-03-10 |
| First published | 2021-03-10 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 4.7 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Thiago Costa |
| Maintainers | thgcst |

## Links

- npm: https://www.npmjs.com/package/react-native-headless-code-input
- Repository: https://github.com/thgcst/react-native-headless-code-input
- Issues: https://github.com/thgcst/react-native-headless-code-input/issues
- npm.io page: https://npm.io/package/react-native-headless-code-input

## Recent versions

- 1.0.7 (latest) — 2021-03-10
- 1.0.6 — 2021-03-10
- 1.0.5 — 2021-03-10
- 1.0.4 — 2021-03-10
- 1.0.3 — 2021-03-10
- 1.0.2 — 2021-03-10
- 1.0.1 — 2021-03-10

## README

# react-native-code-input
A headless hook to handle verification code input.


[![npm](https://img.shields.io/npm/v/react-native-headless-code-input.svg?style=flat-square)](https://www.npmjs.com/package/react-native-headless-code-input)

Inspired by [react-dropzone](https://github.com/react-dropzone/react-dropzone) and [react-table](https://github.com/tannerlinsley/react-table), this is a hook completely UI-free.


## Installation


```bash
npm install react-native-headless-code-input
```
or:
```bash
yarn add react-native-headless-code-input
```


## Usage

```tsx static
import React from 'react';
import { TextInput, TouchableOpacity } from 'react-native';
import useCodeInput from 'react-native-headless-code-input';

import { Container, Wrapper, Field, Value } from './styles';

const App: React.FC = () => {
  const { wrapperProps, fields, inputProps, focusedId, value } = useCodeInput({
    length: 4,
    onFulfill: (code) => handleSubmit(code),
    onChangeText: (code) => handleChange(code),
  });
  return (
    <Container>
      <TouchableOpacity {...wrapperProps}>
        {fields.map(item => (
          <Field
            focused={focusedId === item.id}
            filled={Boolean(item.value)}
            key={item.id}
          >
            <Value>{item.value}</Value>
          </Field>
        ))}
      </TouchableOpacity>
      <TextInput {...inputProps} /> {/* Add this TextInput to handle input value */}
    </Container>
  );
};

export default App;

```

**IMPORTANT**: Under the hood, this lib makes use of [hooks](https://reactjs.org/docs/hooks-intro.html), therefore, using it requires React `>= 16.8`.

---
_Source: https://npm.io/package/react-native-headless-code-input · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
