_reactNative.Keyboard.removeListener is not a function
See original GitHub issueHi! 👋
Firstly, thanks for your work on this project! 🙂
Today I used patch-package to patch react-native-gifted-chat@0.16.3
for the project I’m working on.
Here is the diff that solved my problem:
diff --git a/node_modules/react-native-gifted-chat/lib/MessageContainer.js b/node_modules/react-native-gifted-chat/lib/MessageContainer.js
index 193772a..e26443e 100644
--- a/node_modules/react-native-gifted-chat/lib/MessageContainer.js
+++ b/node_modules/react-native-gifted-chat/lib/MessageContainer.js
@@ -1,6 +1,6 @@
import PropTypes from 'prop-types';
import React from 'react';
-import { FlatList, View, StyleSheet, Keyboard, TouchableOpacity, Text, Platform, } from 'react-native';
+import { FlatList, View, StyleSheet, Keyboard, TouchableOpacity, Text, Platform } from 'react-native';
import LoadEarlier from './LoadEarlier';
import Message from './Message';
import Color from './Color';
@@ -55,18 +55,26 @@ export default class MessageContainer extends React.PureComponent {
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);
+ //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);
+ //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();
};
this.renderTypingIndicator = () => {
if (Platform.OS === 'web') {
This issue body was partially generated by patch-package.
Issue Analytics
- State:
- Created 2 years ago
- Reactions:20
- Comments:18
Top Results From Across the Web
Keyboard.removeListener is not a function #2090 - GitHub
Hello I started getting this error after the last update of react native because the removeListener function was removed in the last update....
Read more >react native - _reactNative.Keyboard.removeListener is not a ...
Now I started to get this exception while trying to navigate between screens: _reactNative.Keyboard.removeListener is not a function. enter ...
Read more >[Solved]-_reactNative.Keyboard.removeListener is not a ...
Coding example for the question _reactNative.Keyboard.removeListener is not a function-React Native.
Read more >Keyboard - React Native
The Keyboard module allows you to listen for native events and react to them, as well as make changes to the keyboard, like...
Read more >Keyboard · React Native
The Keyboard module allows you to listen for native events and react to them, as well as make changes to the keyboard, like...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
May you create a PR with these changes?
Update MessageContainer.js with patch-package (install patch-package before) step 1 – vim node_modules/react-native-gifted-chat/lib/MessageContainer.js (open file with vim filename . Type i to switch into insert mode so that you can start editing the file. Enter or modify the text with your file. Once you’re done, press the escape key Esc to get out of insert mode and back to command mode. Type :wq to save and exit your file.
step 2 npx patch-package react-native-gifted-chat
run the app it will work fine