-
Notifications
You must be signed in to change notification settings - Fork 12.5k
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
When using react-jsx, don't treat "key" property as special unless it's specified as IntrinsicAttribute #58575
Comments
But... you specifically asked for |
If react-jsx is to be used only with react, then why don't we have "jsxImportSource" hardcoded to "react"? Or in other words, the ONLY way to use tsx for anything other than react is to set "jsx" to "preserve", because only "preserve" doesn't have the word react in it. Is that the official stance of TypeScript? |
|
View frameworks exist that are not React, not React-compatible, but still are compatible only in the There's also the |
We don't do type-directed emit, which is what this is asking for.
|
This issue has been marked as "Working as Intended" and has seen no recent activity. It has been automatically closed for house-keeping purposes. |
π Search Terms
jsx, react-jsx, key property
β Viability Checklist
β Suggestion
When "jsx" is set to "react-jsx" the key property is missing from parameters passed to jsx function and instead is passed as separate argument.
For example:
Is compiled into:
My suggestion is to ignore this behavior unless "key" property is defined as
IntrinsicAttribute
.Then, if key is not an intrinsic attribute, the example should compile into:
π Motivating Example
It makes TSX more generic for use by any library, and less React specific
π» Use Cases
This special treatment of "key" property is at odds with libraries other that react that DON'T treat key differently, making if effectively an restricted parameter.
As a workaround, you can merger parameters with key inside jsx function:
But this may lead to weird special cases, like this:
key attribute will override existing key property from
params
.Please make tsx friendly for libraries other than react.
The text was updated successfully, but these errors were encountered: