Skip to content

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

Closed
@SimonGolms

Description

@SimonGolms

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions