Issue number: Resolves#28186
---------
<!-- Please do not submit updates to dependencies unless it fixes an
issue. -->
<!-- Please try to limit your pull request to one type (bugfix, feature,
etc). Submit multiple pull requests if needed. -->
## What is the current behavior?
<!-- Please describe the current behavior that you are modifying. -->
Ionic lifecycle hooks do not execute a cleanup function when the
underlying `useEffect` is unmounted.
```ts
useEffect(() => {
return () => {
console.log('cleanup'); // called
};
});
useIonViewWillEnter(() => {
return () => {
console.log('cleanup'); // never called
};
});
```
Ionic's implementation registers the lifecycle callback to be handled at
a later time, by the page managers. However, it does not keep a
reference to the returned callback, so it cannot execute it when the
`useEffect` is unmounted.
## What is the new behavior?
<!-- Please describe the behavior or changes that are being added by
this PR. -->
- Ionic lifecycle hooks execute dev-specified cleanup functions
## Does this introduce a breaking change?
- [ ] Yes
- [x] No
<!-- If this introduces a breaking change, please describe the impact
and migration path for existing applications below. -->
## Other information
<!-- Any other information that is important to this PR such as
screenshots of how the component looks before and after the change. -->
Dev-build: `7.4.4-dev.11696956070.1faa3cfe`
This PR builds on the changes in #28316.
---------
Co-authored-by: Maria Hutt <maria@ionic.io>
Co-authored-by: Amanda Johnston <90629384+amandaejohnston@users.noreply.github.com>
* fix(): add a page with class ion-page back to ionrouteroutlet - fixes#19146
* wip
* fix(react): attributes show up in dom
* chore(): adding ion-page to core wip
* wip
* fix destroy method
* wrap dom writes in raf
* Add comments
* fix(react): IonPage work
* chore(): ionpage rc3 changelog text
* fix(): syncing ion-page in a new way to get rid of timeout loop
* chore(): ViewStacks refactor out of router
* fix(): remove unused method in router
* wip - before setActiveView rework
* fix(): react router ion page work
* chore(): cleanup and dev release
* fix(): remove need to name tabs
* chore(): adding dev mode helpers
* fix(): adding className prop to back button fixes#19251
* fix(): routerDirection changes
* chore(): rc2 release
* fix(): fix react version in package
* chores(): build kickoff