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

React 19 support #877

Closed
prichey opened this issue Dec 18, 2024 · 7 comments · Fixed by #879
Closed

React 19 support #877

prichey opened this issue Dec 18, 2024 · 7 comments · Fixed by #879
Labels
📦 area/deps This affects dependencies ☂️ area/types This affects typings 💪 phase/solved Post is done 🌐 platform/browser This affects browsers 🐢 platform/node This affects Node 🦋 type/enhancement This is great to have

Comments

@prichey
Copy link

prichey commented Dec 18, 2024

Followup to #871

react-markdown relies on JSX being in the global namespace, which has been removed in @types/react^19.

Per @ChristianMurphy here:

A new issue would be better, we won't support React 19 RC, only GA.

React 19 is now GA, so this issue is to track.

@github-actions github-actions bot added 👋 phase/new Post is being triaged automatically 🤞 phase/open Post is being triaged manually and removed 👋 phase/new Post is being triaged automatically labels Dec 18, 2024
@ChristianMurphy ChristianMurphy added 📦 area/deps This affects dependencies ☂️ area/types This affects typings 🦋 type/enhancement This is great to have 👍 phase/yes Post is accepted and can be worked on labels Dec 18, 2024
@github-actions github-actions bot removed the 🤞 phase/open Post is being triaged manually label Dec 18, 2024

This comment has been minimized.

@ChristianMurphy ChristianMurphy added 🌐 platform/browser This affects browsers 🐢 platform/node This affects Node 🙆 yes/confirmed This is confirmed and ready to be worked on labels Dec 18, 2024
@ChristianMurphy ChristianMurphy pinned this issue Dec 18, 2024
@prichey
Copy link
Author

prichey commented Dec 19, 2024

@wooorm If I upgrade to React 19 in this repo and npm run build, I get the following error:

> [email protected] build
> tsc --build --clean && tsc --build && type-coverage

node_modules/hast-util-to-jsx-runtime/lib/index.d.ts:12:62 - error TS2503: Cannot find namespace 'JSX'.

12 export function toJsxRuntime(tree: Nodes, options: Options): JSX.Element;

In syntax-tree/hast-util-to-jsx-runtime@ae638ba you provide the solution of declaring a global JSX namespace. Would you recommend doing that here?

@0x80
Copy link

0x80 commented Dec 19, 2024

I tried the global JSX namespace suggestion

import type { JSX as Jsx } from "react/jsx-runtime";

declare global {
  namespace JSX {
    type ElementClass = Jsx.ElementClass;
    type Element = Jsx.Element;
    type IntrinsicElements = Jsx.IntrinsicElements;
  }
}

... but it doesn't seem to make a difference for the error I'm getting with React 19:

'ReactMarkdown' cannot be used as a JSX component.
Its type '(options: Readonly) => Element' is not a valid JSX element type.
Type '(options: Readonly) => Element' is not assignable to type '(props: any) => ReactNode | Promise'.
Type 'Element' is not assignable to type 'ReactNode | Promise'.ts(2786)

@steamwings
Copy link

steamwings commented Dec 27, 2024

I tried the global JSX namespace suggestion

import type { JSX as Jsx } from "react/jsx-runtime";

declare global {
  namespace JSX {
    type ElementClass = Jsx.ElementClass;
    type Element = Jsx.Element;
    type IntrinsicElements = Jsx.IntrinsicElements;
  }
}

...

Actually, this suggestion worked for me. Upgraded to Next.js 15 and React 19 without errors.

This comment has been minimized.

@wooorm
Copy link
Member

wooorm commented Jan 2, 2025

Would you recommend doing that here?

Well, what I would recommend doing is speaking to the people that made this change: it’s not a bad change on its own, but it is a very useful feature and there is no alternative, plus this change means that millions of people need to change too. It’s just a lot of work. Not just for us here.

@wooorm wooorm added the 💪 phase/solved Post is done label Jan 2, 2025
@github-actions github-actions bot removed 👍 phase/yes Post is accepted and can be worked on 🙆 yes/confirmed This is confirmed and ready to be worked on labels Jan 2, 2025
@prichey
Copy link
Author

prichey commented Jan 3, 2025

Thanks for getting this merged! Is there a plan to cut a new release?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
📦 area/deps This affects dependencies ☂️ area/types This affects typings 💪 phase/solved Post is done 🌐 platform/browser This affects browsers 🐢 platform/node This affects Node 🦋 type/enhancement This is great to have
Development

Successfully merging a pull request may close this issue.

5 participants