smithy
smithy copied to clipboard
Nested components
trafficstars
Thank you for this crate. It is very useful in our use cases.
Could you please add example of nested components? For example:
<MyButton>
Some text
</MyButton>
I tried something like this:
pub fn render_my_button<'a, 'b>(children: SmithyComponent<'b>) -> SmithyComponent<'a> {
smd!(
<button>{ children }</button>
)
}
// ....
smd!{
<div>
{ render_my_button(smd!(<div>Increment</div>)) }
{ render_my_button(smd!(<div>Decrement</div>)) }
</div>
}
I tried with smd_borrowed, but didn't help. I get this error:
[E0277] the trait bound `smithy::types::Node: smithy::types::Component` is not satisfied.
[Note] the trait `smithy::types::Component` is not implemented for `smithy::types::Node`
Probably I should dig deeper in the code, but asking it is easier.
Thanks. Adding nested component examples is a good idea.
I'm not off the top of my head 100% certain whether this is supported at the moment. Sorry.
I wish I had a better answer :/