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

Support for forwardRef components? #1

Open
FrobtheBuilder opened this issue Dec 9, 2019 · 1 comment
Open

Support for forwardRef components? #1

FrobtheBuilder opened this issue Dec 9, 2019 · 1 comment

Comments

@FrobtheBuilder
Copy link

Usually forwardRef components are declared directly without an explicit type, with the return type of the function itself imposing the component type automatically.
Like such:

const MyComponent = React.forwardRef<MyComponentProps>(({...props}, ref) => (...)

The real type of these components is React.ForwardRefExoticComponent which would be a real drag to need to add to every component manually.
Would it be possible to add a way for this transformer to detect forwardRef calls and add an appropriate displayName without relying on an explicit type annotation in that case?

Great library otherwise though, very convenient.

@aspirisen
Copy link

@FrobtheBuilder are you sure that adding MyComponent.displayName will effect the component name?

Because if you have const MyComponent = React.memo(() => {...}) and you add MyComponent.displayName it has no affect and in devTools the name is unknown

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

No branches or pull requests

2 participants