1.0.10 • Published 5 years ago

@monadstech/react-native-use-otp-verify v1.0.10

Weekly downloads
1
License
MIT
Repository
github
Last release
5 years ago

react-native-use-otp-verify

Wrapper Hook for react-native-otp-verify

Make yourself familiar with react-native-otp-verify before using this hook .

Installation

yarn add react-native-otp-verify @monadstech/react-native-use-otp-verify

or

npm i react-native-otp-verify @monadstech/react-native-use-otp-verify

then Follow instruction of react-native-otp-verify first

Usage

Basic Example

import React from 'react';
import {useOtpVerify} from '@monadstech/rn-use-otp-verify';

const OtpConfirm = () => {
  const [otp, setOtp] = React.useState('');
  const [autoDetectedOtp, autoDetectError] =  useOtpVerify() ;

  React.useEffect(() => {
    if (autoDetectedOtp) {
      setOtp(autoDetectedOtp);
    }
  }, [autoDetectedOtp, handleLogin]);

  ...
};

OTP Parser

Default otpParser checks for following regex : /(\d+)\sis|is\s(\d+).?/g

i.e. otp SMS must be one of following formats

  • .... OTP is 2098 ....

  • .... 2098 is OTP ....

However, you can pass a custom otpParser to useOtpVerify hook.

this otpParser must accept sms as argument and return otp as string or empty string.

LICENSE

MIT LICENSE

1.0.10

5 years ago

1.0.9

5 years ago

1.0.8

5 years ago

1.0.7

5 years ago

1.0.6

5 years ago

1.0.5

5 years ago

1.0.4

5 years ago

1.0.3

5 years ago

1.0.2

5 years ago

1.0.1

5 years ago