I added a listener for my keyboard so I could do something when it shows up,
first I tried keyboardDidShow
and it worked, but I wanted my function to be triggered before keyboard shows up, so according to the react native doc I changed it to keyboardWillShow
. Now it doesn't work at all!
componentDidMount() {
this.keyboardWillShowListener = Keyboard.addListener(
'keyboardWillShow',
()=> this.setState({keyboard_open: true})
);
}
Am I missing something?
Your code is OK. As you can see in the docs,
keyboardWillShow
as well askeyboardWillHide
are generally not available on Android since there is no native corresponding event.
So if you're testing on an Android device, it is not supported but it should work fine on iOS devices.