-
Notifications
You must be signed in to change notification settings - Fork 24.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
SafeAreaView background color changes on production build with New Architecture #45870
Comments
|
|
Thanks @bahadiraraz for the issue, we will look into that. |
Thanks for pointing that out! The reason I used two You can find a discussion about this approach here: Stack Overflow. If there's a more efficient or modern way to handle this, I'm definitely open to suggestions! |
I get curious about alternatives, and I think that something with linear gradients might work. For example: function App() {
return (
<LinearGradient
colors={['red', 'red', 'white', 'green', 'green']}
locations={[0, 0.4, 0.5, 0.6, 1]}
style={{flex:1}}>
<SafeAreaView style={{flex:1, backgroundColor:'transparent'}}>
<View style={{flex:1, backgroundColor: 'white', alignItems: 'center', justifyContent: 'center'}}>
<Text style={{fontSize: 24}}> Hello World </Text>
</View>
</SafeAreaView>
</LinearGradient>
);
} Results in something like this: The fun thing is that you can even extract it to a separate component: function DifferentlyColoredSafeAreaView({topColor, bottomColor, backgroundColor, children}) {
return (
<LinearGradient
colors={[topColor, topColor, backgroundColor, bottomColor, bottomColor]}
locations={[0, 0.4, 0.5, 0.6, 1]}
style={{flex:1}}>
<SafeAreaView style={{flex:1, backgroundColor:'transparent'}}>
<View style={{flex:1, backgroundColor: backgroundColor, alignItems: 'center', justifyContent: 'center'}}>
{children}
</View>
</SafeAreaView>
</LinearGradient>
)
} And then just use it like this: <DifferentlyColoredSafeAreaView
topColor="black"
bottomColor="gray"
backgroundColor="black">
<Text style={{color: 'white', fontSize: 24}}> Hello World </Text>
</DifferentlyColoredSafeAreaView> I'm still going to look into the issue, but as the doc says, the intended use of is to have a top level one that wraps the other components.
|
@cipolleschi This solution worked for me, thank you ! |
Could this issue be related to View Flattening? |
@migueldaipre I thought about that as well, but I was ensured that SafeAreaView is never flattened. But I really haven't had time to investigate it myself and the 2 |
I cannot reproduce this issue on React Native rn-tester. I've tried copying the code from the snack and changing the build configuration in Xcode on the new architecture. |
I cannot reproduce this issue with plain React Native: nor in 0.74.5 nor in 0.75. I suspect that Expo might have something to do with it.
|
Description
After migrating to the New Architecture in React Native, I've encountered an issue with the SafeAreaView background color. The color changes unexpectedly when building the app for release, but works correctly in development mode.
Expected behavior:
The SafeAreaView background colors should remain consistent between development and release builds.
Actual behavior:
The SafeAreaView background colors change unexpectedly in the release build when using the New Architecture.
Steps to reproduce
Steps to reproduce:
npx expo run:ios --device
npx expo run:ios --configuration Release --device
Additional Information:
React Native Version
0.74.3
Affected Platforms
Runtime - Android, Runtime - iOS
Areas
Fabric - The New Renderer
Output of
npx react-native info
Stacktrace or Logs
Reproducer
https://snack.expo.dev/@bahadirs/safeareaview-background-bug
Screenshots and Videos
The text was updated successfully, but these errors were encountered: