DEV Community

Discussion on: How to Pass Components as Props in React

Collapse
 
franciscomendes10866 profile image
Francisco Mendes • Edited

It would render the same way. Basically everything you pass to the prop icon will be rendered in the Button component in the same way as using the prop children.

In this article I simply chose to have the icon wrapper on the Button component because of the css classes I would apply. However I could pass the span along with the icon component and I would just have to remove the conditional rendering (because if the prop icon had no content to render, it wouldn't even take up space in the dom).

I hope I understood your statement 😬