The column to get the header text from
The displayable header text as a string
export function getHeaderText<TData>(column: Column<TData, unknown>): string {
const header = column.columnDef.header as StringOrTemplateHeader<TData, unknown>;
if (header === undefined) return "";
if (typeof header === "string") return header;
if (typeof header === "function") {
const result = (header as () => { props?: { children?: string } })()?.props?.children;
return result ?? "";
}
return String(header);
}
Gets the displayable header text for a column. This is needed because the header text is not always a string. Sometimes it's an HTML or React element.