Skip to content

feat: Lifecycle events not working on IonNav components #29133

Open
@FernetB

Description

@FernetB

Prerequisites

Ionic Framework Version

v7.x

Current Behavior

If I try to use the Lifecycles on Nav components it does not work.

Navigating between Components inside a IonNav does not fire the lifecycle hooks.

This is frustrating because I want to handle the BackButton event on specifict components but i can't if i don't have this hooks
If i handle it in a useEffect then if i have 4 nav components mounted it will trigger the backButton in all of 4, and I only want to trigger on the current view.

Expected Behavior

To have the Lifecycles working on the nav components

Steps to Reproduce

  1. Start in a page with <IonNav />
  2. Push another page that have IonViewWillEnter and IonViewWillLeave
  3. Then go back

You will see that neither of those hooks will trigger

Code Reproduction URL

https://github.com/FernetB/ionic-tabs-bug
No response

Ionic Info

Ionic:

Ionic CLI : 7.1.1
Ionic Framework : @ionic/react 7.7.4

Capacitor:

Capacitor CLI : 5.2.3
@capacitor/android : 5.2.3
@capacitor/core : 5.2.3
@capacitor/ios : 5.2.3

Utility:

cordova-res : 0.15.1
native-run : 1.7.2

System:

NodeJS : v18.16.0
npm : 9.5.1
OS : Windows 10

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