For the DRY principal (don’t repeat yourself), I’d rather not duplicate code. The CountIndicator is used in other parts of the app. I’d like to also be able to use it after the text “New Msgs” like so it appears like this: “New Msgs (3)”
I could duplicate the UX markup for CountIndicator and make a special version of ButtonNav called “ButtonNavWithCount” that incorporates both the button and the (3) count indication.
However, it’s better if possible to somehow use composition to inject the count indication output, since it’s already a component, inside the ButtonNav.
I need it in this case, but I can see this use case coming up time and again, where you want to be able to pass a component to another component as a parameter.