Skip to content

Commit f468d1a

Browse files
authored
docs(lifecycle): clarify when lifecycles are called (#2858)
1 parent d9a33f0 commit f468d1a

File tree

6 files changed

+12
-0
lines changed

6 files changed

+12
-0
lines changed

docs/angular/lifecycle.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@ In addition to the Angular life cycle events, Ionic Angular provides a few addit
4141
| `ionViewWillLeave` | Fired when the component routing from is about to animate. |
4242
| `ionViewDidLeave` | Fired when the component routing to has finished animating. |
4343

44+
These lifecycles are only called on components directly mapped by a router. This means if `/pageOne` maps to `PageOneComponent`, then Ionic lifecycles will be called on `PageOneComponent` but will not be called on any child components that `PageOneComponent` may render.
45+
4446
The difference between `ionViewWillEnter` and `ionViewDidEnter` is when they fire. The former fires right after `ngOnInit` but before the page transition begins, and the latter directly after the transition ends.
4547

4648
For `ionViewWillLeave` and `ionViewDidLeave`, `ionViewWillLeave` gets called directly before the transition away from the current page begins, and `ionViewDidLeave` does not get called until after the new page gets successfully transitioned into (after the new pages `ionViewDidEnter` fires).

docs/react/lifecycle.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ Ionic provides a few lifecycle methods that you can use in your apps:
2424
| `ionViewWillLeave` | Fired when the component routing from is about to animate. |
2525
| `ionViewDidLeave` | Fired when the component routing to has finished animating. |
2626

27+
These lifecycles are only called on components directly mapped by a router. This means if `/pageOne` maps to `PageOneComponent`, then Ionic lifecycles will be called on `PageOneComponent` but will not be called on any child components that `PageOneComponent` may render.
28+
2729
The way you access these methods varies based on if you are using class-based components or functional components. We cover both methods below.
2830

2931
## Lifecycle Methods in Class-Based Components

docs/vue/lifecycle.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ Ionic Framework provides a few lifecycle methods that you can use in your apps:
1717
| `ionViewWillLeave` | Fired when the component routing from is about to animate. |
1818
| `ionViewDidLeave` | Fired when the component routing to has finished animating. |
1919

20+
These lifecycles are only called on components directly mapped by a router. This means if `/pageOne` maps to `PageOneComponent`, then Ionic lifecycles will be called on `PageOneComponent` but will not be called on any child components that `PageOneComponent` may render.
21+
2022
The lifecycles are defined the same way Vue lifecycle methods are - as functions at the root of your Vue component:
2123

2224
```tsx

versioned_docs/version-v6/angular/lifecycle.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@ In addition to the Angular life cycle events, Ionic Angular provides a few addit
4141
| `ionViewWillLeave` | Fired when the component routing from is about to animate. |
4242
| `ionViewDidLeave` | Fired when the component routing to has finished animating. |
4343

44+
These lifecycles are only called on components directly mapped by a router. This means if `/pageOne` maps to `PageOneComponent`, then Ionic lifecycles will be called on `PageOneComponent` but will not be called on any child components that `PageOneComponent` may render.
45+
4446
The difference between `ionViewWillEnter` and `ionViewDidEnter` is when they fire. The former fires right after `ngOnInit` but before the page transition begins, and the latter directly after the transition ends.
4547

4648
For `ionViewWillLeave` and `ionViewDidLeave`, `ionViewWillLeave` gets called directly before the transition away from the current page begins, and `ionViewDidLeave` does not get called until after the new page gets successfully transitioned into (after the new pages `ionViewDidEnter` fires).

versioned_docs/version-v6/react/lifecycle.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ Ionic provides a few lifecycle methods that you can use in your apps:
2424
| `ionViewWillLeave` | Fired when the component routing from is about to animate. |
2525
| `ionViewDidLeave` | Fired when the component routing to has finished animating. |
2626

27+
These lifecycles are only called on components directly mapped by a router. This means if `/pageOne` maps to `PageOneComponent`, then Ionic lifecycles will be called on `PageOneComponent` but will not be called on any child components that `PageOneComponent` may render.
28+
2729
The way you access these methods varies based on if you are using class-based components or functional components. We cover both methods below.
2830

2931
## Lifecycle Methods in Class-Based Components

versioned_docs/version-v6/vue/lifecycle.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ Ionic Framework provides a few lifecycle methods that you can use in your apps:
1717
| `ionViewWillLeave` | Fired when the component routing from is about to animate. |
1818
| `ionViewDidLeave` | Fired when the component routing to has finished animating. |
1919

20+
These lifecycles are only called on components directly mapped by a router. This means if `/pageOne` maps to `PageOneComponent`, then Ionic lifecycles will be called on `PageOneComponent` but will not be called on any child components that `PageOneComponent` may render.
21+
2022
The lifecycles are defined the same way Vue lifecycle methods are - as functions at the root of your Vue component:
2123

2224
```tsx

0 commit comments

Comments
 (0)