New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details
Socket
Book a DemoSign in
Socket

react-native-otp

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-native-otp

OTP Input component for React Native

latest
Source
npmnpm
Version
1.0.0
Version published
Weekly downloads
93
-74.73%
Maintainers
1
Weekly downloads
 
Created
Source

react-native-otp

npm version npm npm

OTP Input component for React Native

Features

  • The behavior is the same with the native input component, the only difference is the OTP UI
  • Can use as Controlled component (support clear OTP, autofill OTP) and Uncontrolled component
  • Easy to customize style
  • No additional dependencies

Preview

Install

NPM

npm install react-native-otp

Yarn

yarn add react-native-otp

Usage

  • Controlled component
import React from 'react';
import { StyleSheet, Text, View, Button } from 'react-native';
import OTPInput from './otp';

export default class App extends React.Component {

  state = {
    otp: ''
  }

  handleOTPChange = (otp) => {
    this.setState({ otp })
  }

  clearOTP = () => {
    this.setState({ otp: undefined })
  }

  autoFill = () => {
    this.setState({ otp: '221198' })
  }

  render() {
    return (
      <View style={styles.container}>
        <Text style={styles.text}>Enter OTP password</Text>

        <OTPInput
          value={this.state.otp}
          onChange={this.handleOTPChange}
          tintColor="#FB6C6A"
          offTintColor="#BBBCBE"
          otpLength={6}
        />

        <Button onPress={this.clearOTP} title="Clear" />
        <Button onPress={this.autoFill} title="Auto fill" />
      </View>
    );
  }
}

const styles = StyleSheet.create({
  container: {
    flex: 1,
    backgroundColor: '#fff',
    alignItems: 'center',
    justifyContent: 'center',
  },
  text: {
    marginBottom: 15
  }
});
  • Uncontrolled component

     <OTPInput
          tintColor="#FB6C6A"
          offTintColor="#BBBCBE"
          otpLength={6}
        />

Available props

NameTypeDefaultDescription
valuestringundefinedThis value will be applied to the TextInput. Use this prop if you want a Controlled Component.
onChangefunction() => nullOn otp input change
otpLengthnumber6length of otp numbers
tintColorstring'#FB6C6A'active cell underline color
offTintColorstring'#BBBCBE'cell under line color
containerStyleobject{}overide container style
cellStyleobject{}overide cell style
all other Text Input propertiesUse this if you want to apply any other property to Text Input

License

MIT

Keywords

react-native

FAQs

Package last updated on 06 Nov 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