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

bug: IonAlert and IonLoading components not open with react v18 and using createRoot #25247

Closed
4 of 7 tasks
SimonGolms opened this issue May 6, 2022 · 5 comments
Closed
4 of 7 tasks
Labels
package: react @ionic/react package type: bug a confirmed bug report

Comments

@SimonGolms
Copy link

SimonGolms commented May 6, 2022

Prerequisites

Ionic Framework Version

  • v4.x
  • v5.x
  • v6.x
  • Nightly

Current Behavior

Upgraded application use to ionic v6 and react v18 and followed the official upgrade guide to react v18:

// https://reactjs.org/blog/2022/03/08/react-18-upgrade-guide.html#updates-to-client-rendering-apis
// Before
import { render } from 'react-dom';
const container = document.getElementById('app');
render(<App tab="home" />, container);

// After
import { createRoot } from 'react-dom/client';
const container = document.getElementById('app');
const root = createRoot(container); // createRoot(container!) if you use TypeScript
root.render(<App tab="home" />);

After updating to client renderings, the <IonAlert /> component do not open/render anymore.

Expected Behavior

Expect <IonAlert /> component to open/render

Steps to Reproduce

Following the Stackblitz example:

  1. Click the button Show Alert Hook to open the alert modal via useIonAlert -> Alert modal open
  2. Click the button Show Alert Component to open the alert modal as a component -> Alert modal not open
  3. Open the index.js file and switch the comments block to use ReactDOM.render()
  4. Click the button Show Alert Component to open the alert modal as a component -> Alert modal open

Code Reproduction URL

https://stackblitz.com/edit/react-1udk9j-3drnwb?file=index.js

Ionic Info

Ionic:

   Ionic CLI       : 6.19.0 (/home/USERNAME/.nvm/versions/node/v16.15.0/lib/node_modules/@ionic/cli)
   Ionic Framework : @ionic/react 6.1.4

Capacitor:

   Capacitor CLI      : 3.5.1
   @capacitor/android : not installed
   @capacitor/core    : 3.5.1
   @capacitor/ios     : not installed

Utility:

   cordova-res : not installed globally
   native-run  : 1.5.0

System:

   NodeJS : v16.15.0 (/home/USERNAME/.nvm/versions/node/v16.15.0/bin/node)
   npm    : 8.8.0
   OS     : Linux 5.10

Additional Information

Same bug as #25118 but with a code example

@ionitron-bot ionitron-bot bot added the triage label May 6, 2022
@sean-perkins
Copy link
Contributor

Thanks for reporting this issue & providing a reproduction! I am seeing the same issue. We will track this as a bug. Will need to do some exploration into the React 18 changes on my end.

@sean-perkins sean-perkins added package: react @ionic/react package type: bug a confirmed bug report labels May 6, 2022
@ionitron-bot ionitron-bot bot removed the triage label May 6, 2022
@SimonGolms
Copy link
Author

SimonGolms commented May 12, 2022

I just found out that the component <IonLoading /> is also affected! https://stackblitz.com/edit/react-1udk9j-pvesdl?file=main.js,index.js

@SimonGolms SimonGolms changed the title bug: IonAlert component not open with react v18 and using createRoot bug: IonAlert and IonLoading components not open with react v18 and using createRoot May 12, 2022
@sean-perkins
Copy link
Contributor

Hello @SimonGolms can you test with this dev build and let me know if the problem persists?

6.1.7-dev.11653598324.17fa560b

The new behaviors for strict mode in development mode uncovered a flaw in our controller component that it could not be unmounted and re-mounted multiple times.

@SimonGolms
Copy link
Author

@sean-perkins I could not reproduce the problem in my local repo and the stackblitz examples - thanks!

@ionitron-bot
Copy link

ionitron-bot bot commented Jun 30, 2022

Thanks for the issue! This issue is being locked to prevent comments that are not relevant to the original issue. If this is still an issue with the latest version of Ionic, please create a new issue and ensure the template is fully filled out.

@ionitron-bot ionitron-bot bot locked and limited conversation to collaborators Jun 30, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
package: react @ionic/react package type: bug a confirmed bug report
Projects
None yet
Development

No branches or pull requests

2 participants