Skip to content

bug: Issues with React 19 types #29991

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

Closed
3 tasks done
aeharding opened this issue Nov 3, 2024 · 16 comments · Fixed by #30217
Closed
3 tasks done

bug: Issues with React 19 types #29991

aeharding opened this issue Nov 3, 2024 · 16 comments · Fixed by #30217
Labels
package: react @ionic/react package type: bug a confirmed bug report

Comments

@aeharding
Copy link
Contributor

Prerequisites

Ionic Framework Version

v8.x

Current Behavior

I've been playing with React 19. I've noticed that Ionic has issues with some of the React 19 types. (This PR is proposed by core React team.)

DefinitelyTyped/DefinitelyTyped#69022

Some components do work, like IonButton. But lots don't, like IonBackButton and IonApp:

'IonBackButton' cannot be used as a JSX component.
  Its type '{ new (props: Props | Readonly<Props>): { context: NavContextState; clickButton: (e: MouseEvent<Element, MouseEvent>) => void; ... 17 more ...; UNSAFE_componentWillUpdate?(nextProps: Readonly<...>, nextState: Readonly<...>, nextContext: any): void; }; new (props: Props, context: any): { ...; }; readonly displayName:...' is not a valid JSX element type.

Expected Behavior

All components work with React 19.

Given that React 19 will be released imminently, I think it would be smart to get ahead of this :)

Steps to Reproduce

  1. Open https://stackblitz.com/edit/i9zdvi-adpda9
  2. Observe type issues with

Code Reproduction URL

https://stackblitz.com/edit/i9zdvi-adpda9

Ionic Info

Running stackblitz

Additional Information

Good news: Ionic works great with 19 so far in my testing, just issues with types :)

@ionitron-bot ionitron-bot bot added the triage label Nov 3, 2024
@tanner-reits
Copy link
Contributor

@aeharding Thanks for letting us know! Since React 19 and the associated types aren't released yet, this will be something we have to wait on for the time being. I'll make sure this is labeled so we can keep track of it and ensure everything is working when React 19 comes around.

@tanner-reits tanner-reits added package: react @ionic/react package type: bug a confirmed bug report and removed triage labels Nov 5, 2024
@aeharding
Copy link
Contributor Author

React 19 released today! 🚀 https://react.dev/blog/2024/12/05/react-19

@jack-hanlon
Copy link

is this fixed now ? wondering whether i should upgrade to React 19 yet or if it will break my ionic codebase ?

@ptmkenny
Copy link

ptmkenny commented Dec 8, 2024

@jack-hanlon No, it's not fixed. When it is fixed, there will be a commit referenced on this issue and the issue will be closed.

@Berkmann18
Copy link

Is there a timeline when this will be fixed?

@aeharding
Copy link
Contributor Author

Not I've heard

Please 👍 up the issue if you would like it addressed

@jadejr
Copy link

jadejr commented Dec 17, 2024

Are the types and perhaps any dependency pinning the only problems with using ionic with react 19?

@ptmkenny
Copy link

@jadejr Things seem to work, but you should test your own project and see what happens. If you're using vite, just remove tsc --noEmit from your build step and the type errors will be ignored, allowing you to use React 19 now.

@YounesAmalouSSCA
Copy link

as @ptmkenny said, if you are using vite, you can skip the tsc command as a temporary workaround, but still, upgrading to React 19 might require ts adjustments.

@zoy-l
Copy link

zoy-l commented Feb 6, 2025

import {
  IonTabs as IonicIonTabs,
  IonTabButton as IonicIonTabButton,
  IonApp as IonicIonApp,
  IonBackButton as IonicIonBackButton
} from '@ionic/react'

export const IonTabs = IonicIonTabs as React.ComponentType<
  ConstructorParameters<typeof IonicIonTabs>[0]
>

export const IonTabButton = IonicIonTabButton as React.ComponentType<
  ConstructorParameters<typeof IonicIonTabButton>[0] & { children: React.ReactNode }
>

export const IonApp = IonicIonApp as React.ComponentType<
  ConstructorParameters<typeof IonicIonApp>[0]
>

export const IonBackButton = IonicIonBackButton as React.ComponentType<
  ConstructorParameters<typeof IonicIonBackButton>[0]
>

Here’s my temporary solution

@hedinasr
Copy link

Do we know on what is the current state of React 19 support?

@ptmkenny
Copy link

@hedinasr The types are broken as described in this issue, but AFAIK there are no other issues.

@aeharding
Copy link
Contributor Author

I saw a dev build to add to package.json to test:

"@ionic/react": "8.4.4-dev.11740669619.1b5165be",
"@ionic/react-router": "8.4.4-dev.11740669619.1b5165be",

Works great for me 😁

ShaneK added a commit that referenced this issue Mar 3, 2025
@ShaneK
Copy link
Member

ShaneK commented Mar 3, 2025

Hey everyone! This issue will be resolved with the release of 8.5, or you can use the dev build @aeharding mentioned if you want to use it before then (that dev build was based off main, so none of the 8.5 stuff will be in it). Thanks for the report!

@ShaneK ShaneK closed this as completed Mar 3, 2025
@ShaneK
Copy link
Member

ShaneK commented Mar 14, 2025

Just following up on this, 8.5.0 has been released and contains the fix for this as a non-dev build

Copy link

ionitron-bot bot commented Apr 13, 2025

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 Apr 13, 2025
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
10 participants