mirror of
https://github.com/ToolJet/ToolJet
synced 2026-05-24 09:28:31 +00:00
fix table going in infinite loop when using dynamic columns without id (#2527)
This commit is contained in:
parent
ef402992f3
commit
65b4be0aac
1 changed files with 16 additions and 1 deletions
|
|
@ -579,7 +579,22 @@ export const Table = React.memo(
|
|||
properties.autogenerateColumns ?? false,
|
||||
id
|
||||
);
|
||||
useDynamicColumn && setGeneratedColumn(generatedColumnFromData);
|
||||
if (useDynamicColumn) {
|
||||
const dynamicColumnHasId = dynamicColumn && dynamicColumn.every((column) => 'id' in column);
|
||||
if (!dynamicColumnHasId) {
|
||||
// if dynamic columns do not have an id then we need to manually compare the generated columns with the columns in the state because the id that we generate for columns without id is a uuid and it will be different every time
|
||||
const generatedColumnsWithoutIds = generatedColumnFromData.map(({ id, ...rest }) => ({
|
||||
...rest,
|
||||
}));
|
||||
const columnsFromStateWithoutIds = generatedColumn.map(({ id, ...rest }) => ({
|
||||
...rest,
|
||||
}));
|
||||
!isEqual(generatedColumnsWithoutIds, columnsFromStateWithoutIds) &&
|
||||
setGeneratedColumn(generatedColumnFromData);
|
||||
return;
|
||||
}
|
||||
setGeneratedColumn(generatedColumnFromData);
|
||||
}
|
||||
}
|
||||
}, [JSON.stringify(tableData), JSON.stringify(dynamicColumn)]);
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue