让我们说我们有这样的嵌套导航器:
<NavigationContainer>
<RootStack.Navigator>
<RootStack.Screen name="Sceen" component={Screen} />
<RootStack.Screen name="MainApp" component={MainApp} />
</RootStack.Navigator>
</NavigationContainer>
// Main app
<MainTabs.Navigator>
<MainTabs.Screen name="NestedStack" component={NestedStack} />
<MainTabs.Screen name="AnotherScreen" component={AnotherScreen} />
</MainTabs.Navigator>
// NestedStack
<NestedStack.Navigator>
<NestedStack.Screen name="Screen1" component={Screen1} />
<NestedStack.Screen name="Screen2" component={Screen2} />
</NestedStack.Navigator>
现在,如果我们从Screen1
导航到Screen2
,似乎整个树都从NavigationContainer
重新渲染。这会大大减慢屏幕过渡的速度。是否可以防止整个树重新渲染并仅重新渲染NestedStack
?