Skip to content

fix(react): present controller overlays in React 18 #25361

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

Merged
merged 2 commits into from
May 31, 2022
Merged

Conversation

sean-perkins
Copy link
Contributor

@sean-perkins sean-perkins commented May 26, 2022

Pull request checklist

Please check if your PR fulfills the following requirements:

  • Tests for the changes have been added (for bug fixes / features)
  • Docs have been reviewed and added / updated if needed (for bug fixes / features)
    • Some docs updates need to be made in the ionic-docs repo, in a separate PR. See the contributing guide for details.
  • Build (npm run build) was run locally and any changes were pushed
  • Lint (npm run lint) has passed locally and any fixes were made for failures

Pull request type

Please check the type of change your PR introduces:

  • Bugfix
  • Feature
  • Code style update (formatting, renaming)
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • Documentation content changes
  • Other (please describe):

What is the current behavior?

Starting in React 18, while in development mode, React will unmount and re-mount a component: https://reactjs.org/blog/2022/03/29/react-v18.html#new-strict-mode-behaviors. 🙃

This causes issues with internal logic within the createControllerComponent that will not present an overlay, if the component will be unmounted.

Issue URL: #25247

What is the new behavior?

  • Resets the flag for unmounting when the component is re-mounted.
  • IonLoading will present when isOpen is set to true
  • IonAlert will present when isOpen is set to true

Does this introduce a breaking change?

  • Yes
  • No

Other information

Dev-build: 6.1.7-dev.11653598324.17fa560b

@sean-perkins sean-perkins requested a review from a team May 26, 2022 20:59
@github-actions github-actions bot added the package: react @ionic/react package label May 26, 2022
Copy link
Contributor

@liamdebeasi liamdebeasi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this a backward compatible change with React 17?

Also is there any way we can write a test for this?

@sean-perkins
Copy link
Contributor Author

Yes, this should be backwards compatible with React 17. In React 17, the unmount lifecycle will not fire initially and the default value of the unmount state is false. So with this change, the value will remain consistent in execution as before.

Writing a test on this change is difficult, as our test app is not on React 18. In theory, our existing tests for alert/loading cover this change being compatible with React 17.

I would like to start an internal discussion though, on the possibility of having a test-app for each major version of each framework we support. For example, with React, there would be a test-app for React 17 and React 18.

@sean-perkins
Copy link
Contributor Author

Dev-build confirmed by issue reporter: #25247 (comment)

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.

2 participants