FedericoDiRosa / react-window-scroller

Window scroller component for react-window
https://federicodirosa.github.io/react-window-scroller/
70 stars 16 forks source link

Add TypeScript support #9

Open AleksandrRadik opened 3 years ago

AleksandrRadik commented 3 years ago

Hello! Thank you for this perfect library! But I have some problem, in my project i use TypeScript, can u help me add support for this?

EskiMojo14 commented 3 years ago

Here's what I came up with:

declare module "react-window-scroller" {
  import { Ref, CSSProperties, ComponentType } from "react";
  import { ListOnScrollProps } from "react-window";
  export type ReactWindowScrollerProps = {
    /** Render props function called with 4 props: `ref`, `outerRef`, `style` and `onScroll` */
    children: ({
      ref,
      outerRef,
      style,
      onScroll,
    }: {
      ref: Ref;
      outerRef: Ref;
      style: CSSProperties;
      onScroll: (props: ListOnScrollProps) => any;
    }) => React.ReactNode;
    /** Timing (ms) for the throttle on window scroll event handler */
    throttleTime?: number;
    /** Set to true if rendering a react-window Grid component (FixedSizeGrid or VariableSizeGrid) */
    isGrid?: boolean;
  };

  // eslint-disable-next-line @typescript-eslint/no-empty-function
  export const ReactWindowScroller: ComponentType<ReactWindowScrollerProps> = () => {};
}