Is there a way I can pass a specialized component to a child by props?
I have a situation where I want to reuse the maximum without duplicating, and I did not understand the right way to do it. Basically I have a card (widget) and inside that card I have a body and there I want to load different things inside it.
The idea is when to use <base />
I have a props "type" where I pass the widget type, so it loads the icon referring to what it needs and in the body it loads the jsx referring to the last type.
I hope it's clear, anything let me know so I can explain it better.
Example, I have a widget.jsx component (which consists of a widgetTitle.jsx, widgetBody.jsx and widgetFooter.jsx)
widget.jsx
<div>
<widgetTitle />
<widgetBody />
<widgetFooter />
</div>
widgetTitle.jsx
<div>
<i>icone</>
<h2>{this.props.titulo}</h2>
</div>
widgetBody.jsx
<div>
{this.props.body}
</div>
widgetFooter.jsx
<div>
<footer>Qualquer coisa do footer</footer>
</div>
I have tb a specialized component.jsx
<div>
<i>icone</>
<span>Status</span>
<i>icone</>
<span>Status</span>
<button>On</button>
</div>
Then can I use the component in this way?
<base titulo="Meu Titulo" texto="Meu texto" body={Aqui carregar o especializado}/>