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

Property 'refs' is missing in type 'Component<HTMLViewProps, any, any>' but required in type 'Component<any, any, any>'. #362

Open
Legend999 opened this issue Jan 7, 2025 · 0 comments

Comments

@Legend999
Copy link

When trying to use the HTMLView component, TypeScript throws the following error:

TS2786: 'HTMLView' cannot be used as a JSX component.
  Its type 'ComponentType<HTMLViewProps>' is not a valid JSX element type.
    Type 'ComponentClass<HTMLViewProps, any>' is not assignable to type 'ElementType'.
      Type 'ComponentClass<HTMLViewProps, any>' is not assignable to type 'new (props: any, deprecatedLegacyContext?: any) => Component<any, any, any>'.
        Property 'refs' is missing in type 'Component<HTMLViewProps, any, any>' but required in type 'Component<any, any, any>'.

55         <HTMLView
            ~~~~~~~~

  node_modules/@types/react/index.d.ts:1021:9
    1021         refs: {
                 ~~~~
    'refs' is declared here.

This issue is essentially the same as the one described in this discussion from another package: DefinitelyTyped/DefinitelyTyped#71404

A workaround was presented for pnpm by utilizing the overrides field. For yarn, you can achieve a similar fix by adding the same version of @types/react from your devDependencies to the resolutions field in your package.json:

  "resolutions": {
    "@types/react": "~18.2.45"
  }
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

1 participant