Skip to content
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

Please update to the latest React Native lifecycles #8

Open
kockok opened this issue Jul 20, 2020 · 3 comments
Open

Please update to the latest React Native lifecycles #8

kockok opened this issue Jul 20, 2020 · 3 comments

Comments

@kockok
Copy link

kockok commented Jul 20, 2020

Hello, this nifty plugin is great.
Screenshot 2020-07-20 at 1 31 46 PM

@ChrisHatchDev
Copy link

+1

Any screen which listens to these keyboard events throws a warning in development.

@sturmenta
Copy link

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)} />

@aboss123
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants