Closed zeo112140 closed 8 years ago
Where are you seeing this warning and what version of react native are you using?
@Andr3wHur5t those warnings are being shown on DeviceEventEmitter.addListener
call.
"react": "^15.1.0",
"react-native": "^0.27.0-rc2"
use Keyboard instead (clojurescript): https://github.com/facebook/react-native/blob/master/Libraries/Components/Keyboard/Keyboard.js
(def Keyboard (js/require "Keyboard"))
(.addListener Keyboard "keyboardWillShow" callback)
thank you, i got it.
------------------ 原始邮件 ------------------
发件人: "misha akovantsev";notifications@github.com;
发送时间: 2016年6月3日(星期五) 晚上10:25
收件人: "Andr3wHur5t/react-native-keyboard-spacer"react-native-keyboard-spacer@noreply.github.com;
抄送: "cc"7453027@qq.com; "Author"author@noreply.github.com;
主题: Re: [Andr3wHur5t/react-native-keyboard-spacer][Warning]keyboardWillShow
event should be registered via the Keyboard module(#23)
@Andr3wHur5t those warnings are being shown on DeviceEventEmitter.addListener call.
"react": "^15.1.0", "react-native": "^0.27.0-rc2"
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub, or mute the thread.
I'm working on a backwards compatible fix, time permitting I'll get a PR out soon.
import {Keyboard} from 'react-native';
Keyboard.addListener('keyboardWillShow', (e) => this._keyboardWillShow(e));
How to remove?
@joonhocho seems for me that this code is working:
componentWillMount() {
this.keyboardWillShowSub = Keyboard.addListener('keyboardWillShow', this.keyboardWillShow.bind(this));
this.keyboardWillHideSub = Keyboard.addListener('keyboardWillHide', this.keyboardWillHide.bind(this));
}
componentWillUnmount() {
this.keyboardWillShowSub.remove();
this.keyboardWillHideSub.remove();
}
Keep in mind that keyboardWillShow
and keyboardWillHide
don't work for Android, whereas keyboardDidShow
and keyboardDidHide
do work. Reference.
You should avoid using this module for android.
Android has native functionality that handles this which will deal with fragmentation of behavior better than this module.
Ref https://github.com/Andr3wHur5t/react-native-keyboard-spacer/issues/46
If you are still seeing this behavior on iOS could file another issue?
async componentWillMount () { Keyboard.addListener('keyboardDidShow', (e) => this.keyboardWillShow(e)); Keyboard.addListener('keyboardDidHide', (e) => this.keyboardWillHide(e)); }
keyboardWillShow = (event) => { console.log('Keyboard is show'); } keyboardWillHide = (event) => { console.log('Keyboard hide'); }
work on ios & android
The Latest version of React-native, import the module ‘react-native-keyboard-spacer’ , found a warning
keyboardWillShow
event should be registered via the Keyboard module,keyboardWillHide
event should be registered via the Keyboard module,How to deal with the warning?