Skip to content
This repository has been archived by the owner on Mar 15, 2024. It is now read-only.

[Question]: Is there any alternative to @radix-ui/react-polymorphic? #358

Open
LucasCaixeta opened this issue Oct 14, 2021 · 4 comments
Open

Comments

@LucasCaixeta
Copy link

LucasCaixeta commented Oct 14, 2021

In our design system (storybook), without the Polymorphic, called as:

type ButtonComponent = Polymorphic.ForwardRefComponent<'button', CustomProps>;

We're losing the "autocomplete" for the component when we import it somewhere.
We want to remove the Polymorphic and use some native alternative from react...
what do you suggest?

Currently, when we remove the Polymorthic we really loose the autocomplete, the props that the component can receive ...

e.g:

<Button    ????      />

after button, when I do command + space do not show the possible props to use... if we remove the Polymorthic usage.

@benoitgrelard
Copy link
Collaborator

We have deprecated the polymorphic package in favour of the asChild prop so we don't really use it anymore.
That said if you can provide a sandbox reproducing your issue, perhaps we can still try to help?

@LucasCaixeta
Copy link
Author

Thanks for the reply @benoitgrelard !
Please, do you have some example or doc reference about the asChild usage? ... then I'll try to use it here

@benoitgrelard
Copy link
Collaborator

benoitgrelard commented Oct 14, 2021

Absolutely! Sorry I should have sent that in the first place.

https://www.radix-ui.com/docs/primitives/overview/styling#changing-the-rendered-element

Basically we moved away from the as prop as it brings polymorphism with it which makes everything more complex, especially type-wise. This new approach doesn't have any of these caveats and so overall performance is way better.

@LucasCaixeta
Copy link
Author

@benoitgrelard will test here today and then I'll tell you something later :)

Thanks a lot!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants