Socket
Socket
Sign inDemoInstall

react-native-confirmation-code-field

Package Overview
Dependencies
0
Maintainers
1
Versions
79
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-native-confirmation-code-field


Version published
Maintainers
1
Install size
29.1 kB
Created

Readme

Source

react-native-confirmation-code-field

npm Travis

A react-native confirmation code field compatible with iOS, Android and Web Platforms (based on this project Migration Guide)

Component features:

  • 🔮 Simple. Easy to use;
  • 🍎 Support "fast paste SMS-code" on iOS. And custom code paste for Android;
  • 🚮 Clearing part of the code by clicking on the cell;
  • blur() and focus() methods;
  • 🛠 Extendable and hackable;
  • 🤓 Readable changelog.

Screenshots

Install

yarn add react-native-confirmation-code-field
# or
npm install react-native-confirmation-code-field

Usage

import React, { Component } from 'react';
import CodeInput from 'react-native-confirmation-code-field';

class App extends Component {
  handlerOnFulfill = code => console.log(code);

  render() {
    return <CodeInput onFulfill={this.handlerOnFulfill} />;
  }
}

How paste or clear code

Paste code can helpful for Android platform when you can read SMS.

import React, { Component, createRef } from 'react';
import CodeInput from 'react-native-confirmation-code-field';

class App extends Component {
  handlerOnFulfill = code => {
    if (isValidCode(code)) {
      console.log(code);
    } else {
      this.clearCode();
    }
  };

  field = createRef();

  clearCode() {
    const { current } = this.field;

    if (current) {
      current.clear();
    }
  }

  pasteCode() {
    const { current } = this.field;

    if (current) {
      current.handlerOnTextChange(value);
    }
  }

  render() {
    return <CodeInput ref={this.field} onFulfill={this.handlerOnFulfill} />;
  }
}

Analogs

How it works?

This component consists of:

  1. Container <View {...containerProps}/>;
  2. Render the "Cells" for the text code inside the container ("Cells" is <TextInput {...cellProps} />);
  3. And over this render invisible <TextInput {...inputProps}/>;
  4. "Cursor" inside cell is simulated component

Keywords

FAQs

Last updated on 24 Apr 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc