Skip to content

JSX allows elements as attribute values, but the transform throws #6004

@loganfsmyth

Description

@loganfsmyth

Input:

<div attr=<div /> />

should become

React.createElement(
  "div",
  { attr: React.createElement("div", null) }
);

but Babel currently throws

Property value of JSXAttribute expected node to be of a type ["JSXElement","StringLiteral","JSXExpressionContainer"] but instead got "CallExpression"

I assume because we're going through the intermediate

<div attr=React.createElement("div", null) />

which is indeed invalid. Probably the easiest fix would be to wrap it, e.g.

<div attr={React.createElement("div", null)} />

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions