Skip to content

bug: Component mount repeatedly while invoking popTo or popToRoot of IonNav #27798

@zhbhun

Description

@zhbhun

Prerequisites

Ionic Framework Version

v7.x

Current Behavior

Hi,

I use IonNav in react, invoking popTo lead to component mount twice.

  1. Each element in IonNav views not have key —— https://github.com/ionic-team/ionic-framework/blob/main/packages/react/src/components/navigation/IonNav.tsx#L22
  2. Each view is wrapped by Portal —— https://github.com/ionic-team/ionic-framework/blob/main/packages/react/src/framework-delegate.tsx#L25
  3. Page A => Page B => Page C => Page D, from Page D popTo Page B. Page D would unmount, then mount agin, finally unmount, It causes to make multiple initialization requests of Page D.

Expected Behavior

Page D unmount only once.

Steps to Reproduce

  1. Build a IonNav and four page - Page A, Page B, Page C, Page D;
  2. Push page one by one;
  3. popTo Page B from Page D;

Code Reproduction URL

https://stackblitz.com/edit/stackblitz-starters-zcyaaq

Ionic Info

Ionic:
Ionic Framework : @ionic/react 7.1.2

System:
NodeJS : v16.19.1
npm : 8.19.3
OS : macOS

Additional Information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions