Skip to content

bug: react 18 with createRoot causes duplicate page transitions #25797

Closed
@liamdebeasi

Description

@liamdebeasi

Prerequisites

Ionic Framework Version

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

Current Behavior

When using Ionic React + React 18 + the new createRoot API, duplicate page transitions occur. This is due to IonPage being unmounted and remounted by react. The registerIonPage function calls for a transition every time a page is registered:

this.handlePageTransition(routeInfo);

However, it was written with the intent that page elements would be registered at most once.

Expected Behavior

I expect there to be only 1 page transition.

Steps to Reproduce

  1. Clone repo.
  2. Run npm install.
  3. Run npm run start.
  4. Click one of the list items in the app. Observe that the page transition occurs twice.

Code Reproduction URL

https://github.com/liamdebeasi/react-18-transition

Ionic Info

Ionic:

   Ionic CLI       : 6.20.1 (/Users/liamdebeasi/Ionic/ionic-cli/packages/@ionic/cli)
   Ionic Framework : @ionic/react 6.2.3

Capacitor:

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

Utility:

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

System:

   NodeJS : v16.11.1 (/Users/liamdebeasi/.nvm/versions/node/v16.11.1/bin/node)
   npm    : 8.0.0
   OS     : macOS Monterey

Additional Information

No response

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