Fixes datatable crash when dimension is empty (#20680)

Fixes #20679

Co-authored-by: Usiel Riedl <usiel.riedl@automattic.com>
This commit is contained in:
Usiel Riedl
2022-07-13 08:54:33 +02:00
committed by GitHub
parent b1020e3062
commit 19247cc92a

View File

@@ -314,9 +314,9 @@ export const useTableColumns = (
const isOriginalTimeColumn =
originalFormattedTimeColumns.includes(key);
return {
id: key,
// react-table requires a non-empty id, therefore we introduce a fallback value in case the key is empty
id: key || index,
accessor: row => row[key],
// When the key is empty, have to give a string of length greater than 0
Header:
colType === GenericDataType.TEMPORAL &&
typeof firstValue !== 'string' ? (