Skip to content

Specifying initialParams on a bottom tab screen with a nested stack navigator causes screens to reappear after being closed. #12141

@RosesAreMerry

Description

@RosesAreMerry

Current behavior

I have a bottom tab navigator which contains two tabs, home and menu, which each contain a stack navigator to handle multiple pages. Menu contains 2 screens, catalog and search, where catalog is the initial screen. If initial params (of any kind, even an empty object) are provided, then if you navigate to search, close search, navigate away from menu, and navigate back to it, search will reappear. If you do not provide initial params, then search will not reappear. This only happens when navigating with the format navigate($tabName, {screen: $screenName}).

The behavior is shown in the repro, one tab is given initial params of {} and the other is given none. One will save the screen, the other will not.

Expected behavior

I expect the tab navigator to not regenerate a closed tab when inital params are provided.

Reproduction

https://snack.expo.dev/M574fTBn08bklhl6cV_qb

Platform

  • Android
  • iOS
  • Web
  • Windows
  • MacOS

Packages

  • @react-navigation/bottom-tabs
  • @react-navigation/drawer
  • @react-navigation/material-top-tabs
  • @react-navigation/stack
  • @react-navigation/native-stack
  • react-native-tab-view

Environment

  • [] I've removed the packages that I don't use
package version
@react-navigation/native ^6.0.8
@react-navigation/bottom-tabs ^6.0.9
@react-navigation/native-stack ^6.7.0
react-native-safe-area-context ^4.4.1
react-native-screens ^3.19.0
react-native ^0.71.7
node 20.15.1
yarn 1.22.22

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions