DEV Community 👩‍💻👨‍💻

Discussion on: Create react subcomponents in a simple way!

Collapse
lexswed profile image
Lex Swed

Every time I see/need to build something like this, I think "wouldn't it be great if it was handled by the platform?". In the end, I always opt out for more permissive usage: document correct usage, but don't enforce it in code, just make sure it doesn't blow up if used incorrectly, while notiying the developer about it.

Collapse
ms_yogii profile image
Yogini Bende Author

Hey Lex, didn't get what you want to say here. Do you think this is not a good pattern? Will you please elaborate your comment?

Collapse
lexswed profile image
Lex Swed

It's a totally valid approach, I'm just complaining on the browser capabilities to write custom components with "children" being handled automatically :)
Like, would be nice if we had not only

<select>
  <option value="1">First</option>
</select>
Enter fullscreen mode Exit fullscreen mode

But also

<card>
  <header>Title</header>
</card>
Enter fullscreen mode Exit fullscreen mode

that would handle incorrect children. I know web-components API exist and there are good examples of it, but it's far from being usable for smaller-scale projects.

Thread Thread
ms_yogii profile image
Yogini Bende Author

True that!