mirror of
https://github.com/zhigang1992/react.git
synced 2026-01-29 22:51:54 +08:00
22 lines
504 B
TypeScript
22 lines
504 B
TypeScript
import React from 'react'
|
|
|
|
export type TableColumnItem = {
|
|
value: string
|
|
label: React.ReactNode | string
|
|
width?: number
|
|
}
|
|
|
|
export interface TableConfig {
|
|
columns: Array<TableColumnItem>
|
|
appendColumn?: (column: TableColumnItem) => void
|
|
removeRow?: (rowIndex: number) => void
|
|
}
|
|
|
|
const defaultContext = {
|
|
columns: [],
|
|
}
|
|
|
|
export const TableContext = React.createContext<TableConfig>(defaultContext)
|
|
|
|
export const useTableContext = (): TableConfig => React.useContext<TableConfig>(TableContext)
|