Fix issue with StackRouter popToTop (#3451)

Previously the state was getting squashed, in this case it would destroy the routeName of the state, which was a route for the parent navigator, who could no longer render properly.
This commit is contained in:
Eric Vicenti 2018-02-06 15:56:39 -08:00 committed by Brent Vatne
parent e97d41cccf
commit 43a1c5ddbd
2 changed files with 2 additions and 0 deletions

View File

@ -27,6 +27,7 @@ class MyNavScreen extends React.Component<MyNavScreenProps> {
onPress={() => navigation.navigate('Profile', { name: 'Jane' })}
title="Go to a profile screen"
/>
<Button onPress={() => navigation.popToTop()} title="Pop to top" />
<Button
onPress={() => navigation.navigate('Photos', { name: 'Jane' })}
title="Go to a photos screen"

View File

@ -175,6 +175,7 @@ export default (routeConfigs, stackConfig = {}) => {
if (action.type === NavigationActions.POP_TO_TOP) {
if (state.index !== 0) {
return {
...state,
isTransitioning: action.immediate !== true,
index: 0,
routes: [state.routes[0]],