I have same problem. So what I done is that create one component called whatever you want eg. SafeScrollView.js
and then render conditionally SafeAreaView
in that component then pass children to that component.
For example :
I have SafeScrollView.js
like below :
import React from 'react';
import { View, SafeAreaView, Platform } from 'react-native';
const SafeScrollView = (props) => {
if (Platform.OS === "ios") {
return (
<View style={props.style}>
{props.children}
</View>
);
}
return (
<SafeAreaView style={props.style}>
{props.children}
</SafeAreaView>
)
}
export default SafeScrollView
Then use SafeScrollView
as a component like below :
<SafeScrollView>
// Your component
</SafeScrollView>
Now, In IOS it will render normal View
component and if device is android it will render SafeScrollView
.
So, you don't have to create separate file.