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

Since 5.7.2: Using JSX fragments requires fragment factory 'React' to be in scope, but it could not be found. #60603

Open
RobertSandiford opened this issue Nov 26, 2024 · 0 comments
Assignees
Labels
Needs Investigation This issue needs a team member to investigate its status.

Comments

@RobertSandiford
Copy link

RobertSandiford commented Nov 26, 2024

πŸ”Ž Search Terms

Search/Keywords: Using JSX fragments requires fragment factory 'React' to be in scope, but it could not be found.

πŸ•— Version & Regression Information

Since 5.7.2. No 5.7.0 or 5.7.1 available. OK in 5.6.3

⏯ Playground Link

Best effort Playground

πŸ’» Code

    <>
        <h1>Logged Out</h1>
    </>

πŸ™ Actual behavior

Since TS 5.7.2 JSX Fragments are no longer accepted.

Compile error: error TS2879: Using JSX fragments requires fragment factory 'React' to be in scope, but it could not be found.

πŸ™‚ Expected behavior

JSX Fragments should continue to work

Additional information about the issue

I have a custom JSX setup, I'm not using React. babel-preset-react is used to transform JSX. This grabs Fragment from the JSX runtime provided and passes this as the node type when creating the element via the JSX runtime. It has been working since TS 4 until now.

Compiled output:

import { jsx as _jsx, Fragment as _Fragment } from "tungsten/jsxRuntime.js";
...
    _jsx(_Fragment, {
        children: _jsx("h1", {
            children: "Logged Out"
        })
    })

The error message about React is odd, JSX and React are independent, why would React anything be needed to use JSX fragments? babel-preset-react with runtime: "automatic" loads jsx functions and the Fragment constant from a specified JSX runtime and does not rely on anything called React.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Needs Investigation This issue needs a team member to investigate its status.
Projects
None yet
Development

No branches or pull requests

3 participants