Skip to content

Enhancement: added option checkKeyMustBeforeSpread of react/jsx-key #2830

Closed
@morlay

Description

@morlay

jsx-runtime landed. but there have different transform results when key before or after props spread

facebook/react#20031

<div key="key "{...props} />;

<div {...props} key="key"/>;

// will convert to 

import { createElement } from "react"
import { jsx } from "react/jsx-runtime"

jsx("div", props, "key")
createElement("div", { ...props, key: "key" }) // only key after props spread do the fallback 

to avoid the fallback to using createElement,
need a rule to limit the key before spread.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions