Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

allow chaining polymorphic components #2196

Draft
wants to merge 5 commits into
base: main
Choose a base branch
from
Draft

allow chaining polymorphic components #2196

wants to merge 5 commits into from

Conversation

mayank99
Copy link
Contributor

@mayank99 mayank99 commented Aug 20, 2024

Changes

This updates the polymorphic implementation so that the as prop can accept an array of components. Each of the components in the array will be rendered sequentially, forming a chain of components that build upon each other.

This array implementation is completely hidden from users, since they should not be passing arrays into as. Think of it as an internal feature to help to us compose multiple primitives together.

This is needed to address a TODO item from #2021 (see thread). We are now able to use ButtonBase and ListItem together.

(Also related but not fully addressed: #2135 (comment)).

Further thoughts: The as prop seems to have fallen out of fashion in the React world. The alternatives are asChild and render props, both of which allow chaining components without any TS issues. However, it is too late to change our component API.

Testing

Pending.

Docs

N/A

@mayank99 mayank99 self-assigned this Aug 20, 2024
Base automatically changed from mayank/polymorphic-div to main August 20, 2024 19:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants