1.0.22 • Published 1 year ago

react-native-otp-ultimate v1.0.22

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

ADDED OPTION TO AUTOCOMPLET ON IOS AND ANDROID, BY THE WAY inputCellLength is limited for the moment

REACT NATIVE OTP ULTIMATE


React Native Component that can used for OTPs and Pins as secure pin input.

npm version npm downloads

Installation


NPM

npm i -S react-native-otp-textinput

YARN

yarn add react-native-otp-textinput

Demo


How to Use


Check the Example react native app for usage.

Platform Support


Supports both Android and iOS.

Props


The following props are applicable for the component along with props supported by react native TextInput component

PropTypeOptionalDefaultDescription
defaultValuestringYes''Default Value that can be set based on OTP / Pin received from parent container.
handleTextChangefuncYesn/acallback with concated string of all cells as argument.
onCodeFilledfuncYesn/awhen code is filled function returns the code so you can perform actions.
inputCountnumberYes4Number of Text Input Cells to be present.
tintColorstringYes#3CB371Color for Cell Border on being focused.
offTintColorstringYes#DCDCDCColor for Cell Border Border not focused.
inputCellLengthnumberYes1Number of character that can be entered inside a single cell.
containerStyleobjectYes{}style for overall container.
textInputStyleobjectYes{}style for text input.
testIDPrefixstringYes'otpinput'testID prefix, the result will be otp_input_0 until inputCount
autoFillFromClipBoardbooleanYestrueif should auto fill from clipboard on android

Helper Functions


Clearing and Setting values to component

// using traditional ref
clearText = () => {
    this.otpInput.clear();
}

setText = () => {
    this.otpInput.setValue("1234");
}

render() {
    return (
        <View>
            <OTPTextInput ref={e => (this.otpInput = e)} >
            <Button title="clear" onClick={this.clearText}>
        </View>
    );
}
// hooks
import React, { useRef } from 'react';

const ParentComponent = () => {
    const otpInput = useRef(null);

    const clearText = () => {
        otpInput.current.clear();
    }

    const setText = () => {
        otpInput.current.setValue("1234");
    }

    return (
        <View>
            <OTPTextInput ref={e => (otpInput = e)} >
            <Button title="clear" onClick={clearText}>
        </View> ̰
    );
}
1.0.22

1 year ago

1.0.21

1 year ago

1.0.20

1 year ago

1.0.19

1 year ago

1.0.17

1 year ago

1.0.16

1 year ago

1.0.15

1 year ago

1.0.14

1 year ago

1.0.13

1 year ago

1.0.12

1 year ago

1.0.11

1 year ago

1.0.9

1 year ago

1.0.8

1 year ago

1.0.7

1 year ago

1.0.5

1 year ago

1.0.4

1 year ago

1.0.3

1 year ago

1.0.2

1 year ago

1.0.1

1 year ago

1.0.0

1 year ago