Closed RishiSetpal777 closed 8 months ago
@RishiSetpal777 is this issue got fixed ?
After checking, I think this happens because of the use of Clipboard from '@react-native-community/clipboard'
whose internal build has been deprecated in the newest Android build.
The error derives from /dist/index.js:44
:
Clipboard.getString().then(code => {
...
}
An easy but temporary way is to use patch-package to disable the function call:
diff --git a/node_modules/@twotalltotems/react-native-otp-input/dist/index.js b/node_modules/@twotalltotems/react-native-otp-input/dist/index.js
index 71580b8..499bee5 100644
--- a/node_modules/@twotalltotems/react-native-otp-input/dist/index.js
+++ b/node_modules/@twotalltotems/react-native-otp-input/dist/index.js
@@ -105,7 +105,7 @@ export default class OTPInputView extends Component {
}
};
this.focusField = (index) => {
- if (index < this.fields.length) {
+ if (index < this.fields.length && this.fields[index]) {
this.fields[index].focus();
this.setState({
selectedIndex: index
@@ -154,8 +154,10 @@ export default class OTPInputView extends Component {
}
}
componentDidMount() {
- this.copyCodeFromClipBoardOnAndroid();
- this.bringUpKeyBoardIfNeeded();
+ // this.copyCodeFromClipBoardOnAndroid();
+ setTimeout(()=>{
+ this.bringUpKeyBoardIfNeeded();
+ },800)
this.keyboardDidHideListener = Keyboard.addListener('keyboardDidHide', this.handleKeyboardDidHide);
}
componentWillUnmount() {
Notice: You should only need // this.copyCodeFromClipBoardOnAndroid();
as other fixes are not relevant to this issue.
Also, this library is not actively maintained anymore, try to folk this project or choose another library would be a good choice.
I had the same issue, tried downgrading package helped!
remove package if you have installed in your project:
"@react-native-community/clipboard"
and downgrade the version to '1.3.5'
.
"@twotalltotems/react-native-otp-input": "^1.3.5"
i had the same issue, what i did to fix it,
npm i @react-native-community/clipboard
After installing this you will likely get an error, then next fix go to this file. node_modules@react-native-community\clipboard\android\src\main\java\com\reactnativecommunity\clipboard\ClipboardModule.java import this : import com.facebook.react.bridge.ReactApplicationContext; convert extended package from ContextBaseJavaModule to ReactContextBaseJavaModule everywhere in file(maybe used at two places) convert this : from: public ClipboardModule(Context context) { super(context); } private ClipboardManager getClipboardService() { return (ClipboardManager) getcontext().getSystemService(getcontext().CLIPBOARD_SERVICE); } to: public ClipboardModule(Context context) { super(new ReactApplicationContext(context)); }
your new code should be looking like `public ClipboardModule(Context context) { super(new ReactApplicationContext(context)); }
public static final String NAME = "RNCClipboard";
@Override public String getName() { return ClipboardModule.NAME; }
private ClipboardManager getClipboardService() {
return (ClipboardManager) getReactApplicationContext().getSystemService(getReactApplicationContext().CLIPBOARD_SERVICE);
}`
try this @react-native-clipboard/clipboard "^1.14.1" @twotalltotems/react-native-otp-input": "^1.3.11",
my current React native version: 0.74.1 It works perfectly for me on both Android and iOS.
Incase you are having this issue -
yarn remove @react-native-community/clipboard @twotalltotems/react-native-otp-input
Then use this library
yarn add @react-native-clipboard/clipboard react-native-otp-entry
Describe the bug i'm using @twotalltotems/react-native-otp-input library. but I'm getting this error. Cannot read property 'getString' of null.
Detailed Error
Details
To Reproduce Steps to reproduce the behaviour:
Smartphone (please complete the following information):
Additional context Packages that are already installed