How to get a height of a Keyboard in React-Native?

后端 未结 4 1061
一整个雨季
一整个雨季 2020-12-08 03:49

I am using React-Navigation in my app and the app consists of StackNavigator with multiple screens, some screens of which have TextInput with autoFocus={true}

4条回答
  •  萌比男神i
    2020-12-08 04:40

    For those of you still looking for an answer to this now you can use hooks.

    import { useKeyboard } from '@react-native-community/hooks'
    
    //Then keyboard like this 
    
    const keyboard = useKeyboard()
    
    console.log('keyboard isKeyboardShow: ', keyboard.keyboardShown)
    console.log('keyboard keyboardHeight: ', keyboard.keyboardHeight)
    

提交回复
热议问题