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

"Component definition is missing display name" when using as #3032

Closed
tu4mo opened this issue Aug 5, 2021 · 2 comments · Fixed by #3110
Closed

"Component definition is missing display name" when using as #3032

tu4mo opened this issue Aug 5, 2021 · 2 comments · Fixed by #3110

Comments

@tu4mo
Copy link

tu4mo commented Aug 5, 2021

I'm getting false missing display name error when using as typecasting.

const Comp = React.forwardRef((props, ref) => <div />) as SomeComponent
Comp.displayName = 'MyCompName'
@tu4mo tu4mo changed the title "Component definition is missing display name" when using "as" "Component definition is missing display name" when using as Aug 5, 2021
@ljharb
Copy link
Member

ljharb commented Aug 6, 2021

What happens if you do const Comp: SomeComponent = React.forwardRef((props, ref) => <div />)? What type is SomeComponent?

If you remove the as SomeComponent, you don't see the warning?

@tu4mo
Copy link
Author

tu4mo commented Aug 6, 2021

I noticed this when I tried Radix UI Polymorphic. Unfortunately using as is the only way it currently works with TypeScript. Warning goes away when I remove the as part.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging a pull request may close this issue.

2 participants