Skip to content

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

@Legend999

Description

@Legend999

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"
  }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions