【发布时间】:2020-05-11 01:03:08
【问题描述】:
我正在将 RN 项目版本 4 迁移到 5。
切换屏幕时出现白色背景闪烁的问题。
在 v4 中,通过在 StackNavigation 选项中设置 cardStyle: { backgroundColor: material.containerBgColor } 解决了这个问题。
但是在 v5 中,我无法用相同的方法修复它:
<Stack.Navigator cardStyle={{ backgroundColor: material.containerBgColor }} ...>
白色闪光又回来了。知道如何解决吗?谢谢。
更新: 导航的结构可能很重要:
const AppTabNavigator = () => (
<Tab.Navigator>
<Tab.Screen name="Home" component={Home} />
<Stack.Screen name="ScreenD" component={ScreenD} />
<Stack.Screen name="ScreenE" component={ScreenE} />
<Stack.Screen name="ScreenF" component={ScreenF} />
</Tab.Navigator>
)
...
<Stack.Navigator
...
cardStyle={{ backgroundColor: material.containerBgColor }}
>
<Stack.Screen name="Home" component={AppTabNavigator} />
<Stack.Screen name="ScreenA" component={ScreenA} />
<Stack.Screen name="ScreenB" component={ScreenB} />
<Stack.Screen name="ScreenC" component={ScreenC} />
</Stack.Navigator>
从 ScreenD 到 ScreenE 会出现闪烁问题。我不确定其他屏幕,因为它们没有发出任何网络请求/异步内容。
【问题讨论】:
-
您找到解决方案了吗?我有同样的问题
-
如果我没记错的话,解决方案是在本地级别的某个地方。您可以在 iOS 的
plist文件和 Android 的gradle文件中设置应用程序 bgcolor。祝你好运! -
我设法通过删除所有 LayoutAnimation 代码来修复故障。谢谢!
-
@andreicovaciu 对我来说 LayoutAnimation 也是造成这种情况的原因,但是仅仅删除所有 LayoutAnimation 代码似乎是一个糟糕的解决方案。
标签: react-native react-navigation react-navigation-stack