react-native-keyboard-listener
react-native-keyboard-listener copied to clipboard
Please update to the latest React Native lifecycles
Hello, this nifty plugin is great.
+1
Any screen which listens to these keyboard events throws a warning in development.
Ended doing my own KeyboardListener file
import React, {useEffect} from 'react';
import {Keyboard} from 'react-native';
const KeyboardListener: React.FC<{
onDidShow: (e: any) => void;
onDidHide: (e: any) => void;
}> = ({onDidShow, onDidHide}) => {
useEffect(() => {
if (onDidShow) Keyboard.addListener('keyboardDidShow', onDidShow);
if (onDidHide) Keyboard.addListener('keyboardDidHide', onDidHide);
return () => {
Keyboard.removeListener('keyboardDidShow', onDidShow);
Keyboard.removeListener('keyboardDidHide', onDidHide);
};
}, []);
return null;
};
export default KeyboardListener;
and using like:
<KeyboardListener onDidShow={() => setKeyboardOpen(true)} onDidHide={() => setKeyboardOpen(false)} />
I submitted a pull request but I guess he has not updated it. Here is the link to the complete remodeled version: https://github.com/aboss123/react-native-keyboard-listener/blob/patch-1/index.js