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.
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.
Share Improve this question edited May 21, 2016 at 11:54 Ivan Chernykh asked May 13, 2016 at 11:02 Ivan ChernykhIvan Chernykh 42.2k13 gold badges136 silver badges148 bronze badges2 Answers
Reset to default 10 +100It seems like you can not use this kind of event listener any more. This seems to be handled by the Keyboard ponent 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