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

transformer: Warning: Spread children are not supported in React. error happens #8690

Open
sapphi-red opened this issue Jan 24, 2025 · 2 comments · Fixed by #8763
Open

transformer: Warning: Spread children are not supported in React. error happens #8690

sapphi-red opened this issue Jan 24, 2025 · 2 comments · Fixed by #8763
Assignees
Labels
C-bug Category - Bug P-high Priority - High

Comments

@sapphi-red
Copy link
Contributor

sapphi-red commented Jan 24, 2025

For input:

export default function() {
  return (
    <>
      {...[1].map((i) => <div>{i}</div>)}
    </>
  );
}

Warning: Spread children are not supported in React. error is output.
This does not happen with esbuild, swc, typescript. But the same error happens with babel.
The actual code I met is this test case in react-router.

Since this code works in other transformers but is not supposed to be supported by react, would it be possible to make the error into warning and align the output with esbuild / SWC? (Maybe the warning is not needed? I'm not sure)

@sapphi-red sapphi-red added the C-bug Category - Bug label Jan 24, 2025
@Boshen
Copy link
Member

Boshen commented Jan 24, 2025

Interesting, let's align and report the problem to babel? Although babel was the initial react implementation :-/

@Boshen Boshen self-assigned this Jan 24, 2025
@Boshen Boshen added the P-high Priority - High label Jan 27, 2025
Boshen added a commit that referenced this issue Jan 28, 2025
@sapphi-red
Copy link
Contributor Author

I found the discussion in babel: babel/babel#3575, babel/babel#7069.
It seems react wants to disallow it (babel/babel#7069 (comment)) and that's the reason of the error, and babel is open for adding a support for it (babel/babel#7069 (comment)).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category - Bug P-high Priority - High
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants