mirror of
https://github.com/zhigang1992/react.git
synced 2026-01-25 05:07:53 +08:00
* refactor(table): redesign interfaces to improve the experience in TypeScript * docs: upgrade to new type exports * style: fix lint warnings
18 lines
471 B
TypeScript
18 lines
471 B
TypeScript
import React from 'react'
|
|
import { TableAbstractColumn } from './table-types'
|
|
|
|
export interface TableConfig<T> {
|
|
columns: Array<TableAbstractColumn<T>>
|
|
updateColumn: (column: TableAbstractColumn<T>) => void
|
|
}
|
|
|
|
const defaultContext = {
|
|
columns: [],
|
|
updateColumn: () => {},
|
|
}
|
|
|
|
export const TableContext = React.createContext<TableConfig<any>>(defaultContext)
|
|
|
|
export const useTableContext = <T>(): TableConfig<T> =>
|
|
React.useContext<TableConfig<T>>(TableContext)
|