After upgrade to 0.26.0-rc version, on iOs this line:
DeviceEventEmitter.addListener('keyboardWillShow', (e)=>this.updateKeyboardSpace(e));
does nothing. When keyboard is open, updateKeyboardSpace
method is never called.
I'm importing DeviceEventEmitter with this:
import React from 'react';
import {DeviceEventEmitter} from 'react-native';
I upgraded from version 0.21 , it was working fine there.
It seems like you can not use this kind of event listener any more. This seems to be handled by the Keyboard component now, which uses native libraries. For iOS it is defined here, the event names seem to be the same; I couldn't find an Android implementation, though. You would need to test if this works, but for iOS this should do the trick:
import {Keyboard} from 'react-native';
Keyboard.addListener('keyboardWillShow', (e)=>this.updateKeyboardSpace(e));
EDIT:
The API explained was internal only. For normal usage, one could use the callbacks on the ScrollResponder. You could use either onKeyboardWillShow
and onKeyboardWillHide
. The ScrollResponder Mixin is used in the ScrollView and ListView, so you may use this props there.
I did a small example on github.
On android, you can use instead these 2 events:
DeviceEventEmitter.addListener('keyboardDidShow', this.keyboardWillShow.bind(this))
DeviceEventEmitter.addListener('keyboardDidHide', this.keyboardWillHide.bind(this))
tested on 0.26.0
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With