Skip to content
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

Proposal: template literal properties #110

Closed
jamesknelson opened this issue Oct 9, 2018 · 1 comment
Closed

Proposal: template literal properties #110

jamesknelson opened this issue Oct 9, 2018 · 1 comment

Comments

@jamesknelson
Copy link

One thing that feels a little odd about JSX is that it's possible to pass single quote ' and double quote " string literals as props:

<div className="test" id='test' />

But it isn't possible to pass template literals in without wrapping them in braces:

// syntax error
<div className=`Panel ${active ? 'active' : ''}` id='test' />

I understand why braces are needed for things like numbers, arrays, or even objects - but template literals feel like another kind of string. They'd also make setting CSS class names like the one above a lot more ergonomic.

One issue I can see is that template literals can be preceded by a tag expression, which doesn't look so great:

// this probably shouldn't work
<div className=tag`Panel ${active ? 'active' : ''}` id='test' />

But perhaps it'd be possible to just support tagless string literals as props?

@jamesknelson
Copy link
Author

Oops, this is a duplicate of #25. Sorry.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant