Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 | 693x 693x 4644x 4644x 693x | // Columns may be given in the old react-table v7 style ({ Header, accessor })
// or the current v8 style ({ header, accessorKey }), so this accepts either
// shape and can't be typed more narrowly than that.
export type LegacyColumn = Record<string, unknown> & {
Header?: string;
header?: string;
accessor?: string;
accessorKey?: string;
};
export function convertOldStyleColumnsToNewStyle(
oldStyleColumns: LegacyColumn[],
): LegacyColumn[] {
const result: LegacyColumn[] = [];
for (const col of oldStyleColumns) {
const newCol = {
id: col.accessor || col.accessorKey, // Use accessor or accessorKey as id
header: col.Header || col.header, // Use Header or header for the column title
accessorKey: col.accessor || col.accessorKey, // Use accessor or accessorKey
...col,
};
result.push({ ...newCol });
}
return result;
}
|