From 2d547830af1169a071cc2fe57624c18fc5d27d7a Mon Sep 17 00:00:00 2001 From: Jorrit Schippers Date: Mon, 18 Jul 2022 14:27:48 +0200 Subject: [PATCH] Use React.ComponentType to provide forwards compatibility with React 18 In older versions of @types/react `ComponentType` is an alias for `ComponentClass` and `SFC`. In @types/react 18+ `SFC` no longer exists and `ComponentType` is an alias for `ComponentClass` and `FunctionComponent`. --- types/react-datasheet.d.ts | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/types/react-datasheet.d.ts b/types/react-datasheet.d.ts index 9ba886b..db77f54 100644 --- a/types/react-datasheet.d.ts +++ b/types/react-datasheet.d.ts @@ -1,4 +1,4 @@ -import { Component, ReactNode, KeyboardEventHandler, MouseEventHandler } from "react"; +import { Component, ReactNode, KeyboardEventHandler, MouseEventHandler, ComponentType } from 'react'; declare namespace ReactDataSheet { /** The cell object is what gets passed to the callbacks and events, and contains the basic information about what to show in each cell. You should extend this interface to build a place to store your data. @@ -110,7 +110,7 @@ declare namespace ReactDataSheet { } /** Optional function or React Component to render the main sheet element. The default renders a table element. To wire it up, pass your function to the sheetRenderer property of the ReactDataSheet component. */ - export type SheetRenderer, V = string> = React.ComponentClass> | React.SFC>; + export type SheetRenderer, V = string> = React.ComponentType>; /** The properties that will be passed to the RowRenderer component or function. */ export interface RowRendererProps, V = string> { @@ -123,7 +123,7 @@ declare namespace ReactDataSheet { } /** Optional function or React Component to render each row element. The default renders a tr element. To wire it up, pass your function to the rowRenderer property of the ReactDataSheet component. */ - export type RowRenderer, V = string> = React.ComponentClass> | React.SFC>; + export type RowRenderer, V = string> = React.ComponentType>; /** The arguments that will be passed to the first parameter of the onCellsChanged handler function. These represent all the changes _inside_ the bounds of the existing grid. The first generic parameter (required) indicates the type of the cell property, and the second generic parameter (default: string) indicates the type of the value property. */ export type CellsChangedArgs, V = string> = { @@ -198,7 +198,7 @@ declare namespace ReactDataSheet { } /** A function or React Component to render each cell element. The default renders a td element. To wire it up, pass it to the cellRenderer property of the ReactDataSheet component. */ - export type CellRenderer, V = string> = React.ComponentClass> | React.SFC>; + export type CellRenderer, V = string> = React.ComponentType>; /** The properties that will be passed to the CellRenderer component or function. */ export interface ValueViewerProps, V = string> { @@ -213,7 +213,7 @@ declare namespace ReactDataSheet { } /** Optional function or React Component to customize the way the value for each cell in the sheet is displayed. If it is passed to the valueViewer property of the ReactDataSheet component, it affects every cell in the sheet. Different editors can also be passed to the valueViewer property of each Cell to control each cell separately. */ - export type ValueViewer, V = string> = React.ComponentClass> | React.SFC>; + export type ValueViewer, V = string> = React.ComponentType>; /** The properties that will be passed to the DataEditor component or function. */ export interface DataEditorProps { @@ -236,7 +236,7 @@ declare namespace ReactDataSheet { } /** A function or React Component to render a custom editor. If it is passed to the dataEditor property of the ReactDataSheet component, it affects every cell in the sheet. Different editors can also be passed to the dataEditor property of each Cell to control each cell separately. */ - export type DataEditor, V = string> = React.ComponentClass> | React.SFC>; + export type DataEditor, V = string> = React.ComponentType>; export interface CellReference { row: number;