Skip to content

[Bug]: Blank Stack back gesture reveals route removed by router.replace #151

Description

@Kokapuk

Version

v3

Stack

Blank Stack

Reanimated Version

v4

Platforms

Android

What happened?

When the currently focused route is replaced using Expo Router's
router.replace(), Blank Stack can retain the replaced route as the screen
underneath the new route during an interactive back gesture.

Given the navigation flow:

A --push--> B --replace--> C

the resulting history is [A, C]. Swiping back from C should therefore reveal A.

Instead, the gesture reveals B. Once the gesture completes, navigation correctly
finishes on A, causing a visible snap from B to A.

The navigation state itself appears to be correct. The issue seems limited to
the screen used as the previous/underlying screen during the interactive
transition.

0827.mp4

Reproduction steps

  1. Run npm install.
  2. Run npx expo start and open the app.
  3. Tap A to navigate to B using router.push("/b").
  4. Tap B to replace it with C using router.replace("/c").
  5. Start an interactive back gesture from C without immediately completing it.

Expected:

A is visible underneath C during the gesture.

Actual:

B is visible underneath C during the gesture. After completing the gesture,
the navigator correctly lands on A, causing a visible snap from B to A.

Relevant navigation code:

// A
onPress={() => router.push("/b")}

// B
onPress={() => router.replace("/c")}

Blank Stack configuration:

<BlankStack
  screenOptions={{
    gestureEnabled: true,
    gestureDirection: "horizontal",
    screenStyleInterpolator: slideFromRightInterpolator,
    transitionSpec: {
      open: Transition.Specs.DefaultSpec,
      close: Transition.Specs.DefaultSpec,
    },
  }}
>
  <BlankStack.Screen name="index" />
  <BlankStack.Screen name="b" />
  <BlankStack.Screen name="c" />
</BlankStack>

Reproduction sample

https://github.com/Kokapuk/react-native-screen-transitions-expo-router-bug

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions