Allowing <{element}></{element}> in JSX to render a variable element
See original GitHub issueYou can now write almost anything in JSX that you can write in JavaScript…except for this case, as far as I can tell. Instead of having to write:
React.createElement(someDynamicElement, props, children)
I think it would be neat to be able to write:
<{someDynamicElement} {...props}>
{children}
</{someDynamicElement}>
It’s not a huge deal, but it would plug the last leak in JSX syntax, allowing people to not have to do a context switch and think about the underlying transform in order to figure out how to do something like this.
Issue Analytics
- State:
- Created 8 years ago
- Reactions:1
- Comments:6 (1 by maintainers)
Top Results From Across the Web
JSX In Depth - React
Specifying The React Element Type. The first part of a JSX tag determines the type of the React element. Capitalized types indicate that...
Read more >how to store jsx element to javascript variable - Stack Overflow
I tried adding ' ' for the div but not getting element properly. It is returing as string. Can someone explain me the...
Read more >Return a Variable in the Render Function in React | Pluralsight
Using JSX, you can create a function and return a set of JSX elements to a variable, and that variable used is to...
Read more >How To Create React Elements with JSX - DigitalOcean
JSX is an abstraction that allows you to write HTML-like syntax in your ... For example, you can't make a variable called null...
Read more >Documentation - DOM Manipulation - TypeScript
It serves as the base interface for every other element interface. For example, the p variable in the code example is of type...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Yea, this works since we’ll just pass whatever is there along to createElement. You can even have a variable that is a string and a DOM component will be created. The point about capitalizing is important.
You need to uppercase it so React knows it’s not an HTML element.