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 WhatsApp Image 2020-07-10 at 4 19 10 PM

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)

Most upvoted comments

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

  1. install yarn add @twotalltotems/react-native-otp-input@1.3.7
  2. install yarn add @react-native-community/clipboard
  3. Run expo start -c to clear the cache

Good luck

Please I really need a fix for this! I installed the clipboard and nothing. The issue is on android!

@react-native-community/clipboard”: “^1.2.3” is installed

Hi @karimcambridge

Can you try to run cd android && ./gradlew clean in your terminal before building project.

Thank you

For Expo users

  1. install yarn add @twotalltotems/react-native-otp-input@1.3.7
  2. install yarn add @react-native-community/clipboard
  3. Run expo start -c to clear the cache

Good luck

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 /:

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

I have this already!

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.

Using expo 😕

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 !!

For Expo users

  1. install yarn add @twotalltotems/react-native-otp-input@1.3.7
  2. install yarn add @react-native-community/clipboard
  3. Run expo start -c to clear the cache

Good luck

Thanks, I didn’t really need step2 and it works fine

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/clipboard I am using react-native 0.63.0

As @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

Hey guys, is there any update for this, please?

Hi. use expo-clipboard!

I understand that we have to use 1.3.7 when we’re with Expo. But what if we find a glitch on 1.3.7? Will you fix it only for the latest version or also for 1.3.7(like 1.3.7.2)?

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.11 and 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 clean 4: cd … && yarn start 5: Open a new terminal tab and run: react-native run-android

Wait for the app to be installed on your emulator.

Doesn’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”

make sure you run expo using -c flag

Doesn’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”