Merge pull request #31271 from Gelio/fix-react-table-hoc-refs

[react-table] allow using refs after applying HOCs
This commit is contained in:
Jesse Trinity
2018-12-13 13:49:10 -08:00
committed by GitHub
4 changed files with 9 additions and 8 deletions

View File

@@ -1,4 +1,4 @@
import { ComponentType } from 'react';
import { ComponentType, ComponentClass } from 'react';
import { TableProps } from '../../index';
@@ -49,8 +49,8 @@ export interface SelectTableHOCOptions {
}
declare function selectTableHOC<Props extends Partial<TableProps>>(
Component: ComponentType<Props>,
WrappedComponent: ComponentType<Props>,
options?: SelectTableHOCOptions
): ComponentType<Props & SelectTableAdditionalProps>;
): ComponentClass<Props & SelectTableAdditionalProps>;
export default selectTableHOC;

View File

@@ -1,9 +1,9 @@
import { ComponentType } from 'react';
import { ComponentType, ComponentClass } from 'react';
import { TableProps } from '../../index';
declare function treeTableHOC<Props extends Partial<TableProps>>(
Component: ComponentType<Props>
): ComponentType<Props>;
WrappedComponent: ComponentType<Props>
): ComponentClass<Props>;
export default treeTableHOC;

View File

@@ -52,6 +52,7 @@ ReactDOM.render(
{...selectTableAdditionalProps}
data={data}
columns={columns}
ref={React.createRef()}
/>,
document.getElementById('root')
);

View File

@@ -4,7 +4,7 @@ import * as ReactDOM from 'react-dom';
import ReactTable, { Column } from 'react-table';
import treeTableHOC from 'react-table/lib/hoc/treeTable';
const SelectTable = treeTableHOC(ReactTable);
const TreeTable = treeTableHOC(ReactTable);
const data = [{ id: 1, name: 'Foo' }, { id: 2, name: 'Bar' }];
@@ -14,6 +14,6 @@ const columns: Column[] = [
];
ReactDOM.render(
<SelectTable data={data} columns={columns} />,
<TreeTable data={data} columns={columns} ref={React.createRef()} />,
document.getElementById('root')
);