Skip to content

Instantly share code, notes, and snippets.

@duytq94
Last active June 25, 2019 03:38
Show Gist options
  • Select an option

  • Save duytq94/be00fac15d895aa65ea76a2fa4e81518 to your computer and use it in GitHub Desktop.

Select an option

Save duytq94/be00fac15d895aa65ea76a2fa4e81518 to your computer and use it in GitHub Desktop.
constructor(props) {
super(props)
this.state = {
isKeyboardShow: false,
keyboardHeight: 0,
}
}
componentWillMount() {
this.keyboardDidShowListener = Keyboard.addListener(
'keyboardDidShow',
this.keyboardDidShow
)
this.keyboardDidHideListener = Keyboard.addListener(
'keyboardDidHide',
this.keyboardDidHide
)
}
componentWillUnmount() {
this.keyboardDidShowListener.remove()
this.keyboardDidHideListener.remove()
}
keyboardDidShow = (e) => {
this.setState({
isKeyboardShow: true,
keyboardHeight: e.endCoordinates.height
})
}
keyboardDidHide = () => {
this.setState({
isKeyboardShow: false
})
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment