-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Keyboard.removeListener is not a function #2090
Comments
in MessageContainer.js constructor this.attachKeyboardListeners = () => {
const { invertibleScrollViewProps: invertibleProps } = this.props;
if (invertibleProps) {
- Keyboard.addListener('keyboardWillShow', invertibleProps.onKeyboardWillShow);
- Keyboard.addListener('keyboardDidShow', invertibleProps.onKeyboardDidShow);
- Keyboard.addListener('keyboardWillHide', invertibleProps.onKeyboardWillHide);
- Keyboard.addListener('keyboardDidHide', invertibleProps.onKeyboardDidHide);
+ this.willShowSub = Keyboard.addListener('keyboardWillShow', invertibleProps.onKeyboardWillShow);
+ this.didShowSub = Keyboard.addListener('keyboardDidShow', invertibleProps.onKeyboardDidShow);
+ this.willHideSub = Keyboard.addListener('keyboardWillHide', invertibleProps.onKeyboardWillHide);
+ this.didHideSub = Keyboard.addListener('keyboardDidHide', invertibleProps.onKeyboardDidHide);
}
};
this.detachKeyboardListeners = () => {
const { invertibleScrollViewProps: invertibleProps } = this.props;
- Keyboard.removeListener('keyboardWillShow', invertibleProps.onKeyboardWillShow);
- Keyboard.removeListener('keyboardDidShow', invertibleProps.onKeyboardDidShow);
- Keyboard.removeListener('keyboardWillHide', invertibleProps.onKeyboardWillHide);
- Keyboard.removeListener('keyboardDidHide', invertibleProps.onKeyboardDidHide);
+ this.willShowSub?.remove();
+ this.didShowSub?.remove();
+ this.willHideSub?.remove();
+ this.didHideSub?.remove();
}; you can apply this fix with https://github.com/ds300/patch-package until the maintainers fix this |
I updated my answer, adding optional chaining operators to the remove() method calls. That should fix your issue. |
This helped a lot! You saved my day! 💚💚❤❤💜💜 |
Anyone knows whats the status of this? |
@xcarpentier Is it possible to do a quick release with a fix as this issue is affecting all users on RN 0.65 and above? |
Yep, I'm on the same boat... Every time having to manually change the listener to remove the errors... |
Receiving same issue on latest release. |
…because removeListener() in official gifted chat is deprecated in RN 0.65 and broke gifted chat completely. See more here: FaridSafi/react-native-gifted-chat#2090
facing this issue when logout from chat screen (after upgrading all libraries) |
@horo42 after updating the MessageContainer file, i get the error node_modules\react-native-gifted-chat\lib\messagecontainer.js: cannot find module 'metro-react-native-babel-preset' I tried to update the package.json file and also tried to add metro-react-natiev-babel-preset in the package and comment out the transform in package json, cleared the npm cache, clean android project but nothing helped.... |
I've just tried Gifted Chat and come across this issue. Simplest possible implementation and I've only just installed it. |
I've already emailed @xcarpentier, he replied back acknowledging he would do a release. Not sure when though... |
can any one make fork of Repo ? and make that edit |
Thank you for the follow up @adhip94! Could we have an estimation of a release date for this fix @xcarpentier ? |
hi has there been any progress? becuase im still facing this isssue. |
@yasimoha and anyone needing a quick fix for production apps, you may apply the patch described by @horo42 here: #2090 (comment) |
This workaround probably pushes the same callback references to the listener callbacks array, and then instantly removes them, leaving the originals (from
Most likely an issue with the optional chaining operator. You can try to fix your config, fall back to if statements, or even |
Could you make a PR with this change so they can merge it? |
Any updates on this? |
Any update? |
just need to update these lines in node_modules/react-native-gifted-chat/lib/MessageContainer.jsthis file. |
update |
I still have this issue ...any update on patch?! |
also me, Im waiting to the fix to be published. |
Sorry, but this issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. BTW Thank you for your contributions 😀 !!! |
I'm not sure a fix has been issued, so please remove the Stale label unless the event listeners have actually been updated. |
Closing as this is fixed in latest beta. |
Hello I started getting this error after the last update of react native because the removeListener function was removed in the last update.
The text was updated successfully, but these errors were encountered: