react-native-otp-input: TypeError: Cannot read property 'getString' of undefined

Getting the error:

TypeError: Cannot read property 'getString' of undefined

This error is located at:
    in OTPInputView (at OTPScreen.js:9)

As mentioned in the pinned issue, I installed @react-native-community/clipboard, still facing the same issue. I did yarn cache clean, deleted node_modules and yarn. lock and even then didn’t work.

My package.json:

"@react-native-community/clipboard": "^1.5.1",
"@twotalltotems/react-native-otp-input": "^1.3.11",

OTPSceen component:

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

const OTPScreen = () => {
  return(
    <View style={styles.otpContainer}>
      <Text>Inside OTP Screen</Text>
	  <OTPInputView 
	      style={{width: '80%', height: 200}}
	      pinCount={4}
	      codeInputFieldStyle={styles.underlineStyleBase}
    	      codeInputHighlightStyle={styles.underlineStyleHighLighted}
	      onCodeFilled = {(code => {
                console.log(`Code is ${code}, you are good to go!`)
	       })}
	  />
    </View>
  );
};

image

Could you please advise, what am I missing here?

Thanks

About this issue

Commits related to this issue

Most upvoted comments

I faced this issue and solved it by using these versions

@twotalltotems/react-native-otp-input”: “1.3.5”, “@react-native-community/clipboard”: “^1.5.1”,

facing same issue but not work with above solution

npm install --save @react-native-community/clipboard npx react-native run-android // worked for me

I faced this issue and solved it by using these versions

@twotalltotems/react-native-otp-input”: “1.3.5”, “@react-native-community/clipboard”: “^1.5.1”,

if installed clipboard npm its working fine npm install --save @react-native-community/clipboard

Steps for reproducing the error:

  1. expo init testProject (bare javascript template)
  2. yarn add @twotalltotems/react-native-otp-input and yarn add @react-native-community/clipboard
  3. In App.js file , added these 2 line:
import OTPInputView from '@twotalltotems/react-native-otp-input'

<OTPInputView pinCount={4} />
  1. expo start

Getting the same error as shown in the screenshot above. Can you please suggest, if there is a workaround or version mismatch issue?

@react-native-community/clipboard”: “^1.5.1”, “@twotalltotems/react-native-otp-input”: “^1.3.11”,

I also getting same error.