-
Notifications
You must be signed in to change notification settings - Fork 46.9k
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
Allow template literals directly in JSX as attributes. #15442
Comments
you are making a joke,too young too simple,stupid brain |
Sorry, my mistake, I didn't realise feature requests had to be large and complex. |
@leeseean Your comment is quite rude and doesn't add any value to this forum. Questions asked in earnest shouldn't ever be belittled. Y-less is simply proposing a quality of life improvement. JSX already supports string literals in the form of Though it may seem a simple thing, writing |
Totally agree. |
I like the idea, but I believe this is invalid JSX. Maybe make a proposal for the JSX spec? |
The JSX syntax is not part of React and is shared by many other libraries, so the specification itself would need to be changed. There's already an open issue for this on the |
Do you want to request a feature or report a bug?
Feature
What is the current behavior?
Template literals are now the recommended way of formatting anything as a string, and the same applies to JSX:
This seems a tiny bit verbose. Not massive mind, but for every one of these you always open with
{`
and always close with`}
. I don't know if those will render correctly, it's hard to type a literal backtick in markdown, so just in casebrace-backtick
andbacktick-brace
. Backticks are not valid in HTML or JSX, so it would be a very small QOL improvement if they could be used directly to specify attributes.What is the expected behavior?
This would be quite a special case of raw string literals. You couldn't use tags, such as:
Without going back to the normal method:
And backticks anywhere but immediately starting an attribute would just be interpreted the same as now - as a literal character:
Which versions of React, and which browser / OS are affected by this issue? Did this work in previous versions of React?
16 at least.
The text was updated successfully, but these errors were encountered: