Skip to content

Replace SKIP_SLICE_TAB_THRESHOLD magic number in useCustomRootStackNavigatorState/index.ios.ts with proper TAB_NAVIGATOR state rehydration #89179

@sumo-slonik

Description

@sumo-slonik

In #89006 we patched an iOS swipe-back regression where the underlying TAB_NAVIGATOR's nested state was lost — once more than two TAB_NAVIGATORs were stacked (workspace → settings → reports via RHP "learn more"), slicing rendered routes dropped the oldest tab's state and iOS swipe-back rehydrated it from scratch with index=0 (Home).

The current fix is a magic-number guard in src/libs/Navigation/AppNavigator/createRootStackNavigator/useCustomRootStackNavigatorState/index.ios.ts:

const SKIP_SLICE_TAB_THRESHOLD = 4;

if (tabCount <= SKIP_SLICE_TAB_THRESHOLD) {
    stateToRender = state; // skip slicing entirely
} else {
    // ...slice as before
}

This unblocks the deploy but is a temporary hotfix — any future flow that stacks more TAB_NAVIGATORs will hit the same bug class.

Proposed solution

Drop the threshold and rebuild the dropped TAB_NAVIGATOR's state from preservedNavigatorStates (already used by cleanPreservedNavigatorStates in NavigationRoot.tsx) when react-navigation rehydrates a sliced-out route on swipe-back. Slicing can stay aggressive for performance once state survives the round-trip.

References

Metadata

Metadata

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions