-
-
Notifications
You must be signed in to change notification settings - Fork 32.4k
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
[docs] Add TypeScript guide on the polymorphic components #32168
Conversation
@mnajdova The codesandbox you linked here has an issue - in lines 9 and 10 a This is likely because ButtonUnstyled does not inherit from OverridableComponent. Because of this, it's not really polymorphic, but it prevents this problem (and hopefully is faster, but I haven't measured it). Any additional props can be placed on a But in principle, yes, it does apply to generic components. There is a note in Select docs describing the need to cast because of this problem. |
Right, I've updated the sandboxed. Let's leave it as is for know then and if necessary we can add similar section on one of the guides for the base components. |
Co-authored-by: Sam Sycamore <[email protected]>
Co-authored-by: Sam Sycamore <[email protected]>
Co-authored-by: Sam Sycamore <[email protected]>
Co-authored-by: Sam Sycamore <[email protected]>
Co-authored-by: Sam Sycamore <[email protected]>
Related to #31314, #31976
Looks like this applies for the base components too, maybe would be worth adding it there too cc @michaldudak
Here is a codendbox describing the issue and the suggested solution:
https://codesandbox.io/s/amazing-lucy-rs38sz?file=/src/App.tsx