Socket
Socket
Sign inDemoInstall

react-native-confirmation-code-field

Package Overview
Dependencies
Maintainers
1
Versions
79
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-native-confirmation-code-field

A react-native component to input confirmation code for both Android and IOS


Version published
Weekly downloads
0
Maintainers
1
Weekly downloads
 
Created
Source

react-native-confirmation-code-field

AppVeyor Travis

A react-native confirmation code input for both IOS and Android (base on this dead project)

MIgration Guide

Features

  • A user-friendly component for inputting confirmation code
  • Built-in type of code input: underline, box, circle
  • Custom position: center, left, right, full width
  • Easy to customize style
  • Check code on finish or return code for async checking
  • Clear code on fail

Screenshot

Preview example

Installation

npm install react-native-confirmation-code-field
# or
yarn add 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} />;
  }
}

Props

PropTypeDefaultDescription
onFulfillfunctionCallback function called when fulfilling code. If compareWithCode is null -> return (code) in callback, else return (code, isValid). Required
Configurate
autoFocusbooleantrueAuto focus on code input
codeLengthnumber5Length of confirmation code -> number of cells
defaultCodestringnullDefault code value, must be the same length as codeLength
compareWithCodestringCode to compare. if null, onFulfill callback return inputted code to check later
ignoreCaseWhenCompareCodebooleanfalseIgnore case when checking code
Style
activeColorstringrgba(255, 255, 255, 1)Color of cells when active
cellBorderWidthnumber1.0Width of cell borders
inactiveColorstringrgba(255, 255, 255, 0.2)Color of cells when inactive
inputPositionstringcenterPosition of code input in its container: left, right, center, full-width
sizenumber40Size of input cells
spacenumber8Space between 2 cells
variantstringborder-boxSome built-in classname: border-box, border-circle, border-b, border-b-t, border-l-r, clear
Customize
getInputPropsfunction<TextInput/> component props, (index: number) => Object
getCodeInputStylefunctionHelp customize any input, must return Style Object or null, example
containerPropsObject<View/> component props
Other
testIDanyHelp in test

Functions

clear() method:
import React, { Component, createRef } from 'react';
import CodeInput from 'react-native-confirmation-code-field';

class App extends Component {
  inputRef = createRef();

  handlerOnIvalidCode() {
    this.inputRef.current.clear();
  }

  render() {
    return (
      <CodeInput
        ref={this.inputRef}
        // ...
      />
    );
  }
}

Example

See EXAMPLE

Usage:

git clone https://github.com/retyui/react-native-confirmation-code-field

cd react-native-confirmation-code-field/examples/rn56

npm install

react-native run-ios
#or
react-native run-android

Keywords

FAQs

Package last updated on 19 Aug 2018

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
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc