Skip to content

Reusing a component ID with setStackRoot causes empty passProps on Android #7149

Open
@jmcountryman

Description

@jmcountryman

🐛 Bug Report

On Android, calling setStackRoot with a layout containing a component ID that is already in the current stack does not properly send passProps to the "updated" component.

Have you read the Contributing Guidelines on issues?

Yes.

To Reproduce

  1. Push a component with a specific ID (id: 'StackRoot1' for this example) onto a stack
  2. Call setStackRoot on the same stack, passing a Layout[] containing in the "history" (in other words, not as the current visible component) a component with the same ID (StackRoot1) and some passProps.
  3. Press back or gesture to navigate "back" to StackRoot1.
  4. On Android, observe the new StackRoot1 component does not have the given passProps; on iOS, observe the new StackRoot1 renders correctly.

Expected behavior

StackRoot1 correctly receives the passProps assigned in the setStackRoot call.

Actual Behavior

On Android, passProps are not passed.

Android.mp4
iOS.mp4

Your Environment

  • React Native Navigation version: 7.16.0
  • React Native version: 0.63.2
  • Platform(s) (iOS, Android, or both?): Both
  • Device info (Simulator/Device? OS version? Debug/Release?):
    • Pixel 3XL running Android 11
    • iOS simulator of an iPhone 12 running iOS 14.5

Reproducible Demo

https://github.com/jmcountryman/react-native-navigation/tree/setStackRoot-passProps (diff)

  1. Launch the app and choose "SideMenu".
  2. Choose "Open Left".
  3. In the left menu choose "Push", and observe the componentId displayed in the center stack is "StackRoot1".
  4. In the left menu choose "Set center stack root" (which sets the center stack to a layout with 2 components, both with passProps) and close the left menu.
  5. Observe the "top" component has a customProp value.
  6. Press back or gesture to navigate back once.
  7. On Android, observe the StackRoot1 component does not have passProps, despite being specified in the call to setStackRoot. On iOS, observe the passProps appear correctly on StackRoot1.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions