Can you please explain why React does not allow simple JSX variables to be used as components to reduce the boilerplate?
me nefcanto
Posted on November 6, 2024
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?
💖 💪 🙅 🚩
me nefcanto
Posted on November 6, 2024
Join Our Newsletter. No Spam, Only the good stuff.
Sign up to receive the latest update from our blog.