You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We have a polymorphic <Text> component, that can be a <span>, <p> or <label>. When using the component normally as <Text as="label" htmlFor="test">Label</Text>everything works good. Component only allows props for tag that we define in "as".
However I want to use <List> as a wrapper to render out a list of <Text> components. This is a simple example, but in real world I would have a complex <Header> component that I can pass in list of polymorphic link props and those get rendered somewhere deep in <Header> component tree.
The problem I have with the approach I tried in codesandbox example is that I make the <List> generic as well and it seems to me that depending on what as i use in the items prop all other items inherit that one generic. I can't figure out how each of the items in <List> items prop would act in "isolation" and only allow props that come from the tag defined in its own "as".
Would be very grateful if we can shoot some ideas if this is even possible.
Activity
ohansemmanuel commentedon Dec 24, 2022
I see. Could you shoot me a code example of the usage here? e.g., with your
Listcomponent as described?