Anjali
Anjali

Reputation: 117

react-native-otp-input giving cannot read property 'getString' of null error

I'm using @twotalltotems/react-native-otp-input library for otp input, but it is giving this error.enter image description here

Here is my code :

 import OTPInputView from '@twotalltotems/react-native-otp-input'
 import React from "react";
 import {StyleSheet,View,TouchableOpacity,Dimensions, KeyboardAvoidingView, Text} from "react-native";

 const screenHeight = Dimensions.get('window').height
 export default OtpScreenComponent = () => {

  return (
    <KeyboardAvoidingView>
    <View style={styles.container}>
    <OTPInputView
    style={{width: '80%', height: 200}}
    pinCount={6}
    autoFocusOnLoad
    codeInputFieldStyle={styles.underlineStyleBase}
    codeInputHighlightStyle={styles.underlineStyleHighLighted}
    onCodeFilled = {(code => {
      console.log(`Code is ${code}, you are good to go!`)
   })}
/>
   <TouchableOpacity onPress={ () => {}}> 
   <Text>Submit Code</Text>
   </TouchableOpacity>
   </View>
   </KeyboardAvoidingView>
  );
 }

I'm using the same code as given in the library readme section but not getting the issue. This is the link of that library : https://www.npmjs.com/package/@twotalltotems/react-native-otp-input

Is there anything else that I should do to use this library like add something in build.gradle file etc. Can someone please help me in this. Thanks in advance.

Upvotes: 3

Views: 3887

Answers (2)

Sarower Jahan
Sarower Jahan

Reputation: 1495

@twotalltotems/react-native-otp-input has dependency with another package @react-native-clipboard/clipboard

Do not use the community version @react-native-community/clipboard. Because it is 4 years old.

Upvotes: 0

Anjali
Anjali

Reputation: 117

I solved this issue by using "@react-native-community/clipboard" library along with "@twotalltotems/react-native-otp-input". So, both the libraries together solved my issue.

Upvotes: 2

Related Questions