fix: Add missing typescript define (#19251)

* fix: Add missing typescript define

* remove withStore

* fix lint
This commit is contained in:
二货机器人 2019-10-16 22:12:52 +08:00 committed by GitHub
parent 5676ea22d2
commit 7d32f99283
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1361,45 +1361,42 @@ class Table<T> extends React.Component<TableProps<T>, TableState<T>> {
}
}
function withStore(
WrappedComponent: typeof Table,
): React.ComponentClass<Omit<TableProps<any>, keyof WithStore>> {
class Component<T> extends React.Component<TableProps<T>> {
static Column = Column;
static ColumnGroup = ColumnGroup;
store: Store;
CheckboxPropsCache: CheckboxPropsCache;
constructor(props: TableProps<T>) {
super(props);
this.CheckboxPropsCache = {};
this.store = createStore({
selectedRowKeys: getRowSelection(props).selectedRowKeys || [],
selectionDirty: false,
});
}
setCheckboxPropsCache = (cache: CheckboxPropsCache) => (this.CheckboxPropsCache = cache);
render() {
return (
<WrappedComponent<T>
{...this.props}
store={this.store}
checkboxPropsCache={this.CheckboxPropsCache}
setCheckboxPropsCache={this.setCheckboxPropsCache}
/>
);
}
}
return Component;
}
polyfill(Table);
export default withStore(Table);
class StoreTable<T> extends React.Component<Omit<TableProps<T>, keyof WithStore>> {
static displayName = 'withStore(Table)';
static Column = Column;
static ColumnGroup = ColumnGroup;
store: Store;
CheckboxPropsCache: CheckboxPropsCache;
constructor(props: TableProps<T>) {
super(props);
this.CheckboxPropsCache = {};
this.store = createStore({
selectedRowKeys: getRowSelection(props).selectedRowKeys || [],
selectionDirty: false,
});
}
setCheckboxPropsCache = (cache: CheckboxPropsCache) => (this.CheckboxPropsCache = cache);
render() {
return (
<Table<T>
{...this.props}
store={this.store}
checkboxPropsCache={this.CheckboxPropsCache}
setCheckboxPropsCache={this.setCheckboxPropsCache}
/>
);
}
}
export default StoreTable;