1.0.0 • Published 2 years ago

react-native-simple-otp-input v1.0.0

Weekly downloads
-
License
ISC
Repository
-
Last release
2 years ago

React Native Pin Input

An input component for PIN codes that is cross-platform, fluid, light, and customisable for React Native.

Installation

$ npm install react-native-simple-otp-input —save

Usage

Import that line for using

$ import PinInputField from 'react-native-simple-otp-input'

Then in your render method

export default App = () = {
const [value, setValue] = useState('');
const [pinDone, setPinDone] = useState(false);
const [AllBorderFlag, setAllBorderFlag] = useState(false);
const MAX_PIN = 4;
  useEffect(() => {
    if (value <= 3) {
      return () => AllBorderFlag(false);
    }
  }, []);
return (
<View>
    <PinInputField
        setPinReady={setPinDone}
        pin={value}
        setPin={setValue}
        maxLength={MAX_PIN}
        AllBorder={AllBorderFlag}
    />
    <Button title="done" onPress={() => setAllBorder(true)} />
</View>
)
}

Props

AttributestypeDescription
pinNumberThe value to show for the input
setPinFunctionCallback function that's called when the text changed
setPinReadyBooleanCheck for maxlength and inputed pin length are same
maxLengthNumberNumber of character for the input
AllBorderBooleanset all input box with border