question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

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

See original GitHub issue

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 https://github.com/ionic-team/ionic-framework/issues/25118 but with a code example

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
sean-perkinscommented, May 6, 2022

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.

0reactions
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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

bug: IonAlert not rendering in develop mode (yarn start) when ...
Changed initial app render to use react-dom/client createRoot, instead of ReactDOM.render, as this gives deprecation warnings in React 18.
Read more >
ReactDOM.render is no longer supported in React 18 - Stack ...
As your error states, ReactDOM.render is no longer supported. So use the new createRoot. As you can see from the code below, ...
Read more >
React v18.0 – React Blog
createRoot : New method to create a root to render or unmount . Use it instead of ReactDOM.render . New features in React...
Read more >
How to Upgrade to React 18
This new check will automatically unmount and remount every component, whenever a component mounts for the first time, restoring the previous ...
Read more >
Strict Mode - React
StrictMode currently helps with: Identifying components with unsafe lifecycles; Warning about legacy string ref API usage; Warning about deprecated findDOMNode ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found