ionic-team / ionic-team/ionic-framework

feat: Lifecycle events not working on IonNav components

Abierto
#29,133 10 comentarios 0 reacciones 0 asignados Ver en GitHub
package: react package: vue type: feature request
Lenguaje dominante
TypeScript
Estrellas
52.7k
Forks
13.3k
Merge medio
1 d 15 h
PR fusionados (30 d)
51

Descripción

### Prerequisites

- [X] I have read the [Contributing Guidelines](https://github.com/ionic-team/ionic-framework/blob/main/.github/CONTRIBUTING.md#creating-an-issue).
- [X] I agree to follow the [Code of Conduct](https://ionicframework.com/code-of-conduct).
- [X] I have searched for [existing issues](https://github.com/ionic-team/ionic-framework/issues) that already report this problem, without success.

### Ionic Framework Version

v7.x

### Current Behavior

If I try to use the [Lifecycles](https://ionicframework.com/docs/react/lifecycle) 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 ``
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_

Guía de contribución

Abrir la guía de contribución

Línea de trabajo

Start by running the reproduction at https://github.com/FernetB/ionic-tabs-bug and compare IonNav behavior with the React lifecycle documentation linked in the issue. Trace how IonNav navigation handles IonViewWillEnter and IonViewWillLeave; done means those hooks fire when views are pushed and popped, without triggering for inactive mounted views.

Escrito por el modelo de indexación a partir del texto del issue.

Evaluación

Stack tecnológico
react, typescript
Área
frontend, mobile
Tipo de issue
Error
Dificultad
4/5
Tiempo estimado
3-5 días
Estado de actividad
Estancado
Claridad
Bastante claro
Aptitud para principiantes
35/100

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.