Replies: 1 comment 6 replies
-
@nshki nice write up! First of all, y'all did the same thing I would have: composed the Icon component inside the Badge template. Did you try something like |
Beta Was this translation helpful? Give feedback.
6 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
This is something that @dylanatsmith and I were discussing recently and would love some thoughts from the community. We were in a situation in which we wanted to render a subcomponent using the parent component's state.
As a minimal example of what we wanted:
And the corresponding render would look something like:
This would ensure that the subcomponent would render in a way that was explicitly defined in the parent component. In the example, the extra
style
param forIconComponent
would be fixed in the context ofBadgeComponent
.However, to currently use slots in this way, the render call needs to look something like:
The nested block on the line
component.icon {}
must be passed otherwise the slot won't render.For our implementation, we ended up ditching using a slot in this situation and rewriting the
BadgeComponent
template to look like:...which works, but I thought that perhaps it would be nicer to be able to do this with an explicit
renders_one
in the parent component, since that could give developers a central place to see all subcomponents.Could it be worth exploring this type of slot usage?
Beta Was this translation helpful? Give feedback.
All reactions