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

IOS keyboard closes when the component is rendering #25225

Closed
mi-mazouz opened this issue Jun 11, 2019 · 2 comments
Closed

IOS keyboard closes when the component is rendering #25225

mi-mazouz opened this issue Jun 11, 2019 · 2 comments
Labels
API: Keyboard Bug Platform: iOS iOS applications. Stale There has been a lack of activity on this issue and it may be closed soon.

Comments

@mi-mazouz
Copy link

mi-mazouz commented Jun 11, 2019

Unfortunately I can't get KeyboardAvoidingView working so I'm trying to handle the problem by myself. So I'm listening on keyboard events and update my component's state consequently! My problem is that the keyboard is closing when setState function trigger a re-render.

class MyComponent extends Component {
 state = {
    isKeyboardOpen: false
  };

 componentWillMount() {
    this.keyboardDidShowListener = Keyboard.addListener('keyboardDidShow', () =>
      this.setState({ isKeyboardOpen: true })
    );
    this.keyboardDidHideListener = Keyboard.addListener('keyboardDidHide', () =>
      this.setState({ isKeyboardOpen: false })
    );
  }

  componentWillUnmount () {
    this.keyboardDidShowListener.remove();
    this.keyboardDidHideListener.remove();
  }

render () {
  const {isKeyboardOpen } = this.state
  return (
    <TextInput style={{bottom: isKeyboardOpen: 150 : 0 }} />
 )
}

React Native version:

React Native Environment Info:
System:
OS: macOS 10.14.5
CPU: (4) x64 Intel(R) Core(TM) i7-7660U CPU @ 2.50GHz
Memory: 1.45 GB / 16.00 GB
Shell: 3.2.57 - /bin/bash
Binaries:
Node: 12.3.0 - /usr/local/bin/node
Yarn: 1.16.0 - /usr/local/bin/yarn
npm: 6.9.0 - /usr/local/bin/npm
Watchman: 4.9.0 - /usr/local/bin/watchman
SDKs:
iOS SDK:
Platforms: iOS 12.2, macOS 10.14, tvOS 12.2, watchOS 5.2
IDEs:
Android Studio: 3.4 AI-183.6156.11.34.5522156
Xcode: 10.2.1/10E1001 - /usr/bin/xcodebuild
npmPackages:
react: 16.8.3 => 16.8.3
react-native: 0.59.9 => 0.59.9

I didn't test on Android, thanks for your help!

@stale
Copy link

stale bot commented Sep 9, 2019

Hey there, it looks like there has been no activity on this issue recently. Has the issue been fixed, or does it still require the community's attention? This issue may be closed if no further activity occurs. You may also label this issue as a "Discussion" or add it to the "Backlog" and I will leave it open. Thank you for your contributions.

@stale stale bot added the Stale There has been a lack of activity on this issue and it may be closed soon. label Sep 9, 2019
@stale
Copy link

stale bot commented Sep 16, 2019

Closing this issue after a prolonged period of inactivity. If this issue is still present in the latest release, please feel free to create a new issue with up-to-date information.

@stale stale bot closed this as completed Sep 16, 2019
@facebook facebook locked as resolved and limited conversation to collaborators Sep 17, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
API: Keyboard Bug Platform: iOS iOS applications. Stale There has been a lack of activity on this issue and it may be closed soon.
Projects
None yet
Development

No branches or pull requests

2 participants