diff --git a/src/data/createData.tsx b/src/data/createData.tsx index c563224..fe57519 100644 --- a/src/data/createData.tsx +++ b/src/data/createData.tsx @@ -7,6 +7,7 @@ import { SelectionProps } from '../rowSelection' import React from 'react' import { ApiRef } from '../api/types' import { Row } from '../types' +import { isFunctionType } from '../helpers' interface CreateDataParams { rows: Row[] @@ -18,16 +19,16 @@ interface CreateDataParams { export function createData({ columns, selection, apiRef, rows }: CreateDataParams) { const cellsList = rows.reduce((list: GridCell[][], row: Row, rowIndex) => { const updatedList = [...list] - const cells = columns.reduce((_cells, header, colIndex) => { + const cells = columns.reduce((_cells, column, colIndex) => { const isDummy = apiRef.current.isMerged({ rowIndex, colIndex }) if (isDummy) { return _cells } const spanInfo = apiRef.current.getSpanProperties({ rowIndex, colIndex }) - const cellValue = row[header.accessor] !== undefined ? row[header.accessor] : '' - const value = header.cellRenderer - ? (header.cellRenderer({ row, column: header }) as any) + const cellValue = row[column.accessor] !== undefined ? row[column.accessor] : '' + const value = column.cellRenderer + ? column.cellRenderer({ row, column }) : formatCellValue(cellValue) _cells.push({ @@ -46,7 +47,11 @@ export function createData({ columns, selection, apiRef, rows }: CreateDataParam cells[cells.length - 1] = { value: ( apiRef.current.selectRow(row[selection.key])} /> diff --git a/src/gridWrapper/interfaces/gridCell.tsx b/src/gridWrapper/interfaces/gridCell.tsx index ea06a80..cbf134f 100644 --- a/src/gridWrapper/interfaces/gridCell.tsx +++ b/src/gridWrapper/interfaces/gridCell.tsx @@ -3,7 +3,7 @@ import React from 'react' export interface GridCell { colSpan?: number rowSpan?: number - value: React.ReactText | JSX.Element + value: React.ReactText | JSX.Element | React.ReactNode style?: React.CSSProperties className?: string gridType?: 'body' | 'header' diff --git a/src/types/dynamic-callback.ts b/src/types/dynamic-callback.ts index 0f043ca..b64f01c 100644 --- a/src/types/dynamic-callback.ts +++ b/src/types/dynamic-callback.ts @@ -7,4 +7,4 @@ export interface DynamicCallbackParams { } export interface DynamicCallback { (params: DynamicCallbackParams): TResult -} \ No newline at end of file +}