If weather
contains a reference to the Sun
function, you can use weather
directly (not via a template literal), but in lower case JSX will assume it's an HTML tag, not a component, and put it in quotes in the resulting React.creatElement
call; so you have to use an initially-capped variable (Weather
instead of weather
):
<Weather />
If weather
contains the string "Sun"
, you can't directly use it to create a Sun
element; you need a reference to the Sun
function, not a string. You need a way to get from the string to the function (an object to look it up on, a Map
, etc.).
You can use template literals elsewhere in JSX, within {}
, since those contain JavaScript expressions. But not to define the component for a tag.