react-native-otp-input: v1.3.10 TypeError: null is not an object (evaluating 'NativeClipboard_1.default.getString')
Native clipboard error
As the title says, I upgraded package to latest version and it stopped working throwing the above mentioned error. Might be because of the release notes that says Change to use Clipboard from @react-native-community/clipboard
To Reproduce The below code was working fine when I am using the older version 1.3.7
<OTPInputView
style={{ width: '60%', height: 50, marginBottom: 20 }}
pinCount={4}
onCodeChanged={code => { this.setState({ code: parseInt(code) }) }}
autoFocusOnLoad
codeInputFieldStyle={styles.underlineStyleBase}
onCodeFilled={(code => {
this.verifyOtp(code);
})}
/>
Screenshots

Smartphone (please complete the following information):
- Device: Android 9.0.0
- OS: Did not check on IOS yet
- Version 1.13.10
- Expo SDK 38.0.0
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Comments: 44 (4 by maintainers)
Hi, i think you can fix this by install @react-native-community/clipboard.
Install the library using either Yarn:
yarn add @react-native-community/clipboard or npm:
npm install --save @react-native-community/clipboard
For Expo users
yarn add @twotalltotems/react-native-otp-input@1.3.7yarn add @react-native-community/clipboardexpo start -cto clear the cacheGood luck
Hi @karimcambridge
Can you try to run
cd android && ./gradlew cleanin your terminal before building project.Thank you
Thanks, I didn’t really need step2 and it works fine
Ok, it works in expo sdk 38 with 1.3.7. Maybe I wasn’t installing the version right before as I was rushing.
Using expo 😕
Working fine in IOS 13.3, issue is only with Android
Im on expo sdk 38.
I tried 1.3.7 and 1.3.10… same issue
Damn /:
H @sathwik77 the problem is @react-native-community/clipboard is not automatically linking in Android. And install @react-native-community/clipboard helps solve the problem. It really works for me so can you please try again?
Thank you.
Hi @karimcambridge Expo doesn’t use @react-native-community/x packages. Can you try the older version of our package (v1.3.7)? Thank you
with Expo 44, nothing is working !!
This worked like charm
Use react-native link @react-native-community/clipboard after install clipboard library worked for me.
Thanks, @ericdao-ttt Working after adding
@react-native-community/clipboardI am using react-native 0.63.0As @ericdao-ttt said, Expo does not use community packages, they added support for few in SDK 38, but not for community clipboard yet. But, in this case v1.3.7 should work with expo 38 as it does not use community clipboard in it, I guess. Don’t know why v1.3.7 is failing in expo 38
Pleasee use expo-clipboard.
Btw. I was also fighting with that issue:
react-native-otp-input@1.3.7<- 1.3.7 is important. I had^1.3.11and no matter what I did the above solution only works with that version.Using react-native@0.61.2 (bare workflow). What I did to resolve this error was: 0: Stop react-native server (if running) 1: remove node_modules folder 2: Re-install node_modules 3:
cd android && ./gradlew clean4: cd … && yarn start 5: Open a new terminal tab and run:react-native run-androidWait for the app to be installed on your emulator.
make sure you run expo using
-cflagDoesn’t work for: “react-native”: “https://github.com/expo/react-native/archive/sdk-40.0.1.tar.gz”, “@twotalltotems/react-native-otp-input”: “^1.3.7”