tttstudios / react-native-otp-input

Tiny Javascript library which provides an elegant UI for user to input one time passcode.
MIT License
535 stars 241 forks source link

v1.3.10 TypeError: null is not an object (evaluating 'NativeClipboard_1.default.getString') #87

Closed sathwik77 closed 4 years ago

sathwik77 commented 4 years ago

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

sathwik77 commented 4 years ago

Working fine in IOS 13.3, issue is only with Android

eric-dao37 commented 4 years ago

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

sathwik77 commented 4 years ago

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!

eric-dao37 commented 4 years ago

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.

karimcambridge commented 4 years ago

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

eric-dao37 commented 4 years ago

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

karimcambridge commented 4 years ago

Using expo :/

eric-dao37 commented 4 years ago

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

sathwik77 commented 4 years ago

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

Version 1.3.7 works with Expo 37.0.0 perfectly, both v1.3.7 and v1.3.10 does not work with expo SDK 38.0.0. I did not try v1.3.10 with expo 37 though

karimcambridge commented 4 years ago

Im on expo sdk 38.

I tried 1.3.7 and 1.3.10... same issue

Damn /:

sathwik77 commented 4 years ago

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

Kailash23 commented 4 years ago

Thanks, @ericdao-ttt Working after adding @react-native-community/clipboard I am using react-native 0.63.0

karimcambridge commented 4 years ago

Ok, it works in expo sdk 38 with 1.3.7. Maybe I wasn't installing the version right before as I was rushing.

tylerthedeveloper commented 4 years ago

im still getting this error on sdk 38, version 1.3.7, and after installing the clipboard package

tylerthedeveloper commented 4 years ago

finally got it worked after cleaning npm cache, android simulator cache (wiped) and expo cache (expo start -c).

Confirming expo 38 does work with 1.3.8

swapnilroy1995 commented 4 years ago

I was getting the same issue. Tried all suggestions here but the issue persisted.

Still managed to get away with it by using the older way of clipboard by importing it from react-native in the index.js in the node modules where react-native community where there is a folder named clipboard or you can look into the red box to see the specific path..

1) import React, { Component } from 'react'; import { View, TextInput, TouchableWithoutFeedback, Keyboard, Platform, I18nManager, Clipboard } from 'react-native'; //import Clipboard from '@react-native-community/clipboard'; import styles from './styles';

after that I used Async and Await in the function where the clipboard was being used.

2) this.checkPinCodeFromClipBoard =async () => { const { pinCount, onCodeFilled } = this.props; const regexp = new RegExp(^\d{${pinCount}}$); await Clipboard.getString().then(code => { if (this.hasCheckedClipBoard && regexp.test(code) && (this.clipBoardCode !== code)) { this.setState({ digits: code.split(""), }, () => { this.blurAllFields(); this.notifyCodeChanged(); onCodeFilled && onCodeFilled(code); }); } this.clipBoardCode = code; this.hasCheckedClipBoard = true; }).catch(() => { }); };

Note: The issue got away with the step in (2) but somehow the function was getting called repeatedly infinitely. This was solved when I imported clipboard from react-native in step(1). Don't know how this happened but it worked.

kdt1802 commented 4 years ago

Use react-native link @react-native-community/clipboard after install clipboard library worked for me.

sumit1317 commented 4 years ago

finally got it worked after cleaning npm cache, android simulator cache (wiped) and expo cache (expo start -c).

Confirming expo 38 does work with 1.3.8

1.3.8 is not available ..

nurimanizam commented 3 years ago

Use react-native link @react-native-community/clipboard after install clipboard library worked for me.

Using expo bare workflow, this fixes the android issue.

arjdev69 commented 3 years ago

i just re-install app

shivam-880 commented 3 years ago

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"

SirPhemmiey commented 3 years ago

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

karimcambridge commented 3 years ago

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

Hi. use expo-clipboard!

minaibrahimsaid commented 3 years ago

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

Good luck

minaibrahimsaid commented 3 years ago

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

meenabassem commented 3 years ago

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

ArifSanaullah commented 3 years ago

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.

bushcode commented 3 years ago

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

Thank you so much. This worked for me

mightym commented 3 years ago

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.

KuniyoshiKamimura commented 3 years ago

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)?

karimcambridge commented 3 years ago

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.

SamVinston001 commented 2 years ago

Its running on simulator and Emulator but not working in android phones. is there any solution comment please....

devcoderbuzz commented 2 years ago

i am using "expo": "~44.0.0", and "@twotalltotems/react-native-otp-input": "^1.3.11", still failing :( Any luck for this issue ??

devcoderbuzz commented 2 years ago

Not sure how they can close the issue when it's not working on the latest versions.

devcoderbuzz commented 2 years ago

this latest version killed my whole day :(

mightym commented 2 years ago

@devcoderbuzz you have to use 1.3.7 https://github.com/tttstudios/react-native-otp-input/issues/87#issuecomment-903655096

devcoderbuzz commented 2 years ago

@devcoderbuzz you have to use 1.3.7 #87 (comment)

Now in android when I navigate from the previous screen to this, the keyboard does not show up :( If the previous screen keyboard was open, then when I come to this screen its shows. But if I close in the previous screen and then navigate, then this screen does not show. Also, how do we integrate this from auto-populating the otp from messages?

da45 commented 2 years ago

with Expo 44, nothing is working !!

baltagih2 commented 2 years ago

Also happens on Expo 42, only fix I found is using v1.3.7, all others crash

wandieinnocents commented 2 years ago

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

UmarFKhawaja commented 2 years ago

Thanks @wandieinnocents your solution is what worked for me. I am pretty much on the latest Expo at the time of writing.

wandieinnocents commented 2 years ago

@UmarFKhawaja You are most welcome :)-

allisson-lima commented 2 years ago

This will work, uninstall the app and install again it will work

wandieinnocents commented 2 years ago

Yes it will work well.

On Sun, May 15, 2022 at 11:16 PM Allisson Lima @.***> wrote:

This will work, uninstall the app and install again it will work

— Reply to this email directly, view it on GitHub https://github.com/tttstudios/react-native-otp-input/issues/87#issuecomment-1127018471, or unsubscribe https://github.com/notifications/unsubscribe-auth/ADZLGIQBXPKX67KP6RY77WLVKFLSTANCNFSM4OWNFPQQ . You are receiving this because you were mentioned.Message ID: @.***>

--

ABOUT ME:“ Name: Wenareeba Innocent Facebook: Wandie Innocents Twitter: @InnocentsWandie Instagram: @coolwandie Mobile/Whatsapp: +256 706 382 - 817 Other: +256 770 440-053

Pursuing : Masters of Science in Computer Science Profession: Software Engineer / UX Designer

If your actions inspire others to dream more, learn more, do more and become more, you are a leader.” i love to inspire the young generation.