Andr3wHur5t / react-native-keyboard-spacer

Plug and play react-native keyboard spacer view.
MIT License
1.56k stars 219 forks source link

[Warning]`keyboardWillShow` event should be registered via the Keyboard module #23

Closed zeo112140 closed 8 years ago

zeo112140 commented 8 years ago

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?

Andr3wHur5t commented 8 years ago

Where are you seeing this warning and what version of react native are you using?

akovantsev commented 8 years ago

@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)
zeo112140 commented 8 years ago

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.

Andr3wHur5t commented 8 years ago

I'm working on a backwards compatible fix, time permitting I'll get a PR out soon.

deju commented 8 years ago

import {Keyboard} from 'react-native';

Keyboard.addListener('keyboardWillShow', (e) => this._keyboardWillShow(e));

joonhocho commented 8 years ago

How to remove?

JanPeter commented 8 years ago

@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();
  }
gsavvid commented 7 years ago

Keep in mind that keyboardWillShow and keyboardWillHide don't work for Android, whereas keyboardDidShow and keyboardDidHide do work. Reference.

Andr3wHur5t commented 7 years ago

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?

revi4n4 commented 6 years ago

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