Skip to content

Commit 2d54783

Browse files
committed
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`.
1 parent 13b5c35 commit 2d54783

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

types/react-datasheet.d.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Component, ReactNode, KeyboardEventHandler, MouseEventHandler } from "react";
1+
import { Component, ReactNode, KeyboardEventHandler, MouseEventHandler, ComponentType } from 'react';
22

33
declare namespace ReactDataSheet {
44
/** 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 {
110110
}
111111

112112
/** 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. */
113-
export type SheetRenderer<T extends Cell<T, V>, V = string> = React.ComponentClass<SheetRendererProps<T, V>> | React.SFC<SheetRendererProps<T, V>>;
113+
export type SheetRenderer<T extends Cell<T, V>, V = string> = React.ComponentType<SheetRendererProps<T, V>>;
114114

115115
/** The properties that will be passed to the RowRenderer component or function. */
116116
export interface RowRendererProps<T extends Cell<T, V>, V = string> {
@@ -123,7 +123,7 @@ declare namespace ReactDataSheet {
123123
}
124124

125125
/** 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. */
126-
export type RowRenderer<T extends Cell<T, V>, V = string> = React.ComponentClass<RowRendererProps<T, V>> | React.SFC<RowRendererProps<T, V>>;
126+
export type RowRenderer<T extends Cell<T, V>, V = string> = React.ComponentType<RowRendererProps<T, V>>;
127127

128128
/** 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. */
129129
export type CellsChangedArgs<T extends Cell<T, V>, V = string> = {
@@ -198,7 +198,7 @@ declare namespace ReactDataSheet {
198198
}
199199

200200
/** 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. */
201-
export type CellRenderer<T extends Cell<T, V>, V = string> = React.ComponentClass<CellRendererProps<T, V>> | React.SFC<CellRendererProps<T, V>>;
201+
export type CellRenderer<T extends Cell<T, V>, V = string> = React.ComponentType<CellRendererProps<T, V>>;
202202

203203
/** The properties that will be passed to the CellRenderer component or function. */
204204
export interface ValueViewerProps<T extends Cell<T, V>, V = string> {
@@ -213,7 +213,7 @@ declare namespace ReactDataSheet {
213213
}
214214

215215
/** 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. */
216-
export type ValueViewer<T extends Cell<T, V>, V = string> = React.ComponentClass<ValueViewerProps<T, V>> | React.SFC<ValueViewerProps<T, V>>;
216+
export type ValueViewer<T extends Cell<T, V>, V = string> = React.ComponentType<ValueViewerProps<T, V>>;
217217

218218
/** The properties that will be passed to the DataEditor component or function. */
219219
export interface DataEditorProps<T, V = string> {
@@ -236,7 +236,7 @@ declare namespace ReactDataSheet {
236236
}
237237

238238
/** 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. */
239-
export type DataEditor<T extends Cell<T, V>, V = string> = React.ComponentClass<DataEditorProps<T, V>> | React.SFC<DataEditorProps<T, V>>;
239+
export type DataEditor<T extends Cell<T, V>, V = string> = React.ComponentType<DataEditorProps<T, V>>;
240240

241241
export interface CellReference {
242242
row: number;

0 commit comments

Comments
 (0)