diff --git a/src/components/Consents/Consents.tsx b/src/components/Consents/Consents.tsx index 7b9448042067662bfd628fc6fd1541a72a7cebdf..b2505bc99d374aaa561ec0dc53fcff7392d3f50c 100644 --- a/src/components/Consents/Consents.tsx +++ b/src/components/Consents/Consents.tsx @@ -72,7 +72,7 @@ export const Consents: React.FC<{ type: 'sge' | 'grdf' }> = ({ type }) => { }, []) const checkSelectedNodes = useCallback(() => { - if (gridApi) { + if (gridApi && !gridApi.isDestroyed()) { const newNodes = gridApi.getRenderedNodes() const idsToCheck: string[] = selectedNodes .filter(node => node.isSelected) @@ -110,7 +110,7 @@ export const Consents: React.FC<{ type: 'sge' | 'grdf' }> = ({ type }) => { const resetSelection = useCallback(() => { if (gridApi) { setIsShowingSelection(false) - gridApi.setRowData(consents) + gridApi.setGridOption('rowData', consents) gridApi.deselectAll() setSelectedNodes([]) } @@ -137,9 +137,9 @@ export const Consents: React.FC<{ type: 'sge' | 'grdf' }> = ({ type }) => { ) const continueSelection = useCallback(() => { - if (gridApi) { + if (gridApi && !gridApi.isDestroyed()) { setIsShowingSelection(false) - gridApi?.setRowData(consents) + gridApi.setGridOption('rowData', consents) const newNodes = gridApi.getRenderedNodes() // We have to select nodes that have already been selected since we cannot pass a Node array to init AgGrid const idsToCheck: string[] = selectedNodes @@ -155,7 +155,7 @@ export const Consents: React.FC<{ type: 'sge' | 'grdf' }> = ({ type }) => { const showCurrentSelection = useCallback(() => { setIsShowingSelection(true) const dataFromNode = selectedNodes.map(item => item.data) - selectedNodes && gridApi?.setRowData(dataFromNode) + selectedNodes && gridApi?.setGridOption('rowData', dataFromNode) gridApi?.selectAll() }, [gridApi, selectedNodes])