Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(react): route with redirect will mount page #28961

Merged
merged 1 commit into from Feb 6, 2024
Merged

Conversation

sean-perkins
Copy link
Contributor

Issue number: resolves #28838


What is the current behavior?

In #28316 we resolved a longstanding misconfiguration where event listeners being added to the page were not removed. This was due to incorrect usage of .bind creating a new instance of the callback functions.

By removing the event listener for ionViewDidLeave, before the component has actually unmounted in react, resulted in the registered destroy callback to not fire:

ionViewDidLeave() {
this.ionViewDidLeaveCallbacks.forEach((cb) => {
const destructor = cb();
if (cb.id) {
this.ionViewDidLeaveDestructorCallbacks.push({ id: cb.id, destructor });
}
});
this.componentCanBeDestroyed();
}
and
this.ionLifeCycleContext.onComponentCanBeDestroyed(() => {
if (!this.props.mount) {
if (this._isMounted) {
this.setState(
{
show: false,
},
() => this.props.removeView()
);
}
}
});

This resulted in a scenario that using a Redirect could cause the wrong view to be unmounted (the entering view) and leave the user on an empty screen.

What is the new behavior?

  • ionViewDidEnter event listener is not removed while the component is unmounting. The browser will naturally remove the event listener when the element node is detached from the DOM.
  • Users are no longer presented with a white screen after clicking a route that uses a redirect.

Does this introduce a breaking change?

  • Yes
  • No

Other information

Dev-build: 7.6.7-dev.11706567011.11e782a9

@github-actions github-actions bot added the package: react @ionic/react package label Feb 2, 2024
@sean-perkins sean-perkins marked this pull request as ready for review February 2, 2024 05:23
@sean-perkins sean-perkins added this pull request to the merge queue Feb 6, 2024
Merged via the queue into main with commit 5777ce2 Feb 6, 2024
56 checks passed
@sean-perkins sean-perkins deleted the sp/FW-5897 branch February 6, 2024 23:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
package: react @ionic/react package
Projects
None yet
Development

Successfully merging this pull request may close these issues.

bug: React Router renders white page with Redirect
2 participants