r/reactnative • Android • Sep 20 '20

Programmatically Hide Bottom tab when keyboard open.

Post image
198 Upvotes

32 comments sorted by

View all comments

3

u/[deleted] Sep 20 '20

You should use will show and will hide on iOS, makes it much smoother

6

u/KajiTetsushi Sep 20 '20

The Platform.OS property can take care of that.

import { Platform } from 'react-native;'

const showEventType = Platform.OS === 'ios' ? 'keyboardWillShow' : 'keyboardDidShow';
const hideEventType = Platform.OS === 'ios' ? 'keyboardWillHide' : 'keyboardDidHide';

Then use them in the Keyboard.addListener() method.

2

u/[deleted] Sep 20 '20

Yup