Skip to content

transformer: incorrect isStaticChildren value for fragments with static children #8650

@sapphi-red

Description

@sapphi-red

For input,

const foo = () => {
  return <>
    <p>foo</p>
    <p>foo</p>
  </>
}

oxc tranform outputs:

var _jsxFileName = "foo.jsx";
import { jsxDEV as _jsxDEV, Fragment as _Fragment } from "react/jsx-dev-runtime";
const foo = () => {
        return _jsxDEV(_Fragment, { children: [_jsxDEV("p", { children: "foo" }, void 0, false, {
                fileName: _jsxFileName,
                lineNumber: 4,
                columnNumber: 5
        }, this), _jsxDEV("p", { children: "foo" }, void 0, false, {
                fileName: _jsxFileName,
                lineNumber: 5,
                columnNumber: 5
        }, this)] }, void 0, false);
};

The forth argument of _jsxDEV for _Fragment is false. This should be true.
reproduction using transform function from rolldown

If this is false, Warning: Each child in a list should have a unique "key" prop. error happens with React.

esbuild try with the same input

I found this while testing rolldown-vite on ecosystem-ci.

Metadata

Metadata

Assignees

Labels

C-bugCategory - Bug

Type

No type

Priority

None yet

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions