ionic-framework icon indicating copy to clipboard operation
ionic-framework copied to clipboard

Lifecycle events called in wrong order

Open georgechr opened this issue 6 years ago • 4 comments

Bug Report

Ionic version: [x] 4.0.0

Current behavior: When changing the root page the lifecycle events of the previous and next page seem to fire out of order. So, lets say page A is currently displayed. Navigating to page B fires the lifecycle events in the following order:

  1. Page B: ngOnInit
  2. Page B: ionViewWillEnter
  3. Page B: ionViewDidEnter
  4. Page A: ngOnDestroy

(ionViewWillLeave and ionViewDidLeave do not fire at all)

Expected behavior: I would expect that page A fires ngOnDestroy or ionViewWillLeave or ionViewDidLeave before page B's 'enter' events

georgechr avatar Feb 04 '19 07:02 georgechr

I am experiencing this partially in 4.0.1. ionViewWillLeave does trigger, but is too late when using swipe to go back. In Ionic 3 ionViewWillLeave will trigger before the transform animation. Now in Ionic 4 it is triggered after the transition is started so the user can drag de current page away and then it will stay that way, leaving translateX at 100%.

martijnlutgens avatar Feb 22 '19 08:02 martijnlutgens

Hi there,

Thanks for the issue! Would you be able to provide a repository with the code required to reproduce this issue?

Thanks!

liamdebeasi avatar Mar 28 '19 16:03 liamdebeasi

I have opened a separate issue for this with a repository link: https://github.com/ionic-team/ionic/issues/17600. This had already been confirmed as a bug. Any idea when this is going on deck?

martijnlutgens avatar Mar 29 '19 07:03 martijnlutgens

any updates on it in 2022? maybe you can suggest some workaround? I work with a webcomponent that clear own dependencies when destroy happens, and component doesn't work because destroy fired after new view created

annmirosh avatar May 17 '22 08:05 annmirosh