I'm using KeyboardAvoidingView and I want to pass a prop 'behaviour' to it in case the platform is IOS and none in case it's android. I don't wanna write two separate JSX component declarations for the same. Is there a way to decide to pass a prop or not. Also react-native's docs don't mention any default value for the behaviour props which I could have set conditionally otherwise.
Based on the platform the component should be declared the following way
FOR IOS
<KeyboardAvoidingView behavior="padding" style={modalContainer} >
{this.props.children} //I've lots of children here and they're composed inside of the keyboardavoidingview and i'm not using this.props.children as they're in the same parent component
</KeyBoardAvoidingView>
FOR ANDROID
<KeyboardAvoidingView style={modalContainer} >
{this.props.children}
</KeyBoardAvoidingView>
You can conditionally pass a prop by passing the value
or undefined
<KeyboardAvoidingView behavior={platform="android"? "padding": undefined} style={modalContainer} >
{this.props.children}
</KeyBoardAvoidingView>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With