I didn't add the KeyboardAvoidingView diagram in previous tweet, so here's an overview:
If you have a TextInput on the lower half of your screen, the keyboard will cover it. The fix is the behavior prop, which takes "padding", "height", or "position".
Here is how it differs across OS:
🤖 Android: "height" -> it shrinks the height of the view.
🍎 iOS: "padding" -> it adds bottom padding equivalent to the keyboard's height.
To do this intelligently, use the "Platform" API to detect the OS and assign the behavior dynamically!
behavior={Platform.OS === 'ios' ? 'padding' : 'height'}
Wrapped up another session of Mobile Dev Cohort.
Topics covered:
✅ What is mobile development
✅ Types of Mobile Apps
✅ Intro to React Native & Expo
✅ Basic react native components like Text, Button, Scrollview, Flatlist
Thanks
@surajtwt_,
@nirudhuuu,
@Hiteshdotcom and
@ChaiCodeHQ team.
#chaicode