This content originally appeared on DEV Community and was authored by me nefcanto
Let's say I have static JSX content that I want to reuse across my website.
const Contacts = <div>
<div>+1 111 11 11</div>
<div>company at server.com</div>
</div>
Of course, I can't render it as <Contacts />
. I however can render it as {Contacts}
.
Can you please tell me why should I add boilerplate code to this JSX constant to be able to render it like <Contacts />
?
I'm curious about the technical why part. What prevented React developers to enable it?
This content originally appeared on DEV Community and was authored by me nefcanto
me nefcanto | Sciencx (2024-11-06T08:51:10+00:00) Can you please explain why React does not allow simple JSX variables to be used as components to reduce the boilerplate?. Retrieved from https://www.scien.cx/2024/11/06/can-you-please-explain-why-react-does-not-allow-simple-jsx-variables-to-be-used-as-components-to-reduce-the-boilerplate/
Please log in to upload a file.
There are no updates yet.
Click the Upload button above to add an update.