Commit 32d7a4d3 by Ryan McKinley Committed by GitHub

TablePanel: avoid toArray for memoizedData (#23744)

parent 1ca3ce59
......@@ -72,7 +72,18 @@ export const Table: FC<Props> = memo((props: Props) => {
// React table data array. This data acts just like a dummy array to let react-table know how many rows exist
// The cells use the field to look up values
const memoizedData = useMemo(() => {
return data.fields.length > 0 ? data.fields[0].values.toArray() : [];
if (!data.fields.length) {
return [];
}
// Check if an array buffer already exists
const buffer = (data.fields[0].values as any).buffer;
if (Array.isArray(buffer) && buffer.length === data.length) {
return buffer;
}
// For arrow tables, the `toArray` implementation is expensive and akward *especially* for timestamps
return Array(data.length).fill(0);
}, [data]);
// React-table column definitions
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment