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?
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:But it isn't possible to pass template literals in without wrapping them in braces:
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:
But perhaps it'd be possible to just support tagless string literals as props?