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

ref type mismatch? #110

Open
smajl opened this issue Apr 2, 2020 · 0 comments
Open

ref type mismatch? #110

smajl opened this issue Apr 2, 2020 · 0 comments

Comments

@smajl
Copy link

smajl commented Apr 2, 2020

Expected behavior

Typescript will compile without errors.

Current behavior

Ref types mismatch.

TS2322: Type '(instance: ReactInstance) => void' is not assignable to type 'string | ((instance: HTMLDivElement | null) => void) | RefObject<HTMLDivElement> | null | undefined'.   Type '(instance: ReactInstance) => void' is not assignable to type '(instance: HTMLDivElement | null) => void'.     Types of parameters 'instance' and 'instance' are incompatible.       Type 'HTMLDivElement | null' is not assignable to type 'ReactInstance'.         Type 'null' is not assignable to type 'ReactInstance'.  index.d.ts(143, 9): The expected type comes from property 'ref' which is declared here on type 'DetailedHTMLProps<HTMLAttributes<HTMLDivElement>, HTMLDivElement>'

Steps to reproduce

function MyComponent() {
  const renderList: React.ComponentProps<typeof List>['itemsRenderer'] = (items, ref) => (
    <div className={classes.root} ref={ref}>
      ...
    </div>
  );

  return (
    <List
      itemsRenderer={renderList}
      ...
    />
  );
}

Context (environment)

  • Version: 3.0.9
  • TypeScript: 3.8.3
  • Platform: Win 10 64bit
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