react-intersection-list icon indicating copy to clipboard operation
react-intersection-list copied to clipboard

ref type mismatch?

Open smajl opened this issue 5 years ago • 0 comments
trafficstars

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

smajl avatar Apr 02 '20 12:04 smajl