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

refactor: improve useKeyboard cross-platform compatibility #401

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

sabuhiteymurov
Copy link

Summary

This pull request enhances the useKeyboard hook in the react-native-community/hooks library to improve cross-platform compatibility for keyboard events. Currently, the hook supports both keyboardWillShow and keyboardWillHide events on iOS, but for Android, it uses keyboardDidShow and keyboardDidHide events. To ensure consistent behavior across platforms, this update introduces conditional event listeners based on the platform.

The motivation behind this change is to provide a consistent and reliable experience for handling keyboard events in a cross-platform React Native application. By utilizing the appropriate keyboard events based on the platform, this enhancement aims to improve the overall user experience and streamline the development process.

Test Plan

What's required for testing (prerequisites)?

  • Ensure that the react-native-community/hooks library is installed.
  • Set up a React Native project with appropriate dependencies.

What are the steps to reproduce (after prerequisites)?

  1. Import and use the useKeyboard hook in a React Native component.
  2. Test the component on both iOS and Android devices or simulators.
  3. Observe the behavior of the keyboardShown, coordinates, and keyboardHeight values when the keyboard is shown and hidden.

Compatibility

OS Implemented
iOS
Android
Web

Checklist

  • I have tested this on a device and a simulator
  • I added the documentation in README.md
  • I updated the typed files (TS and Flow)
  • I've created a snack to demonstrate the changes: LINK HERE

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

Successfully merging this pull request may close these issues.

1 participant