Skip to content

Commit a237d51

Browse files
authored
fix(AnalyticalTable): move ResizeObserver creation into effect to avoid blank tables on second mount (#420)
1 parent e0f8603 commit a237d51

File tree

1 file changed

+5
-6
lines changed
  • packages/main/src/components/AnalyticalTable

1 file changed

+5
-6
lines changed

packages/main/src/components/AnalyticalTable/index.tsx

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -248,15 +248,14 @@ const AnalyticalTable: FC<TableProps> = forwardRef((props: TableProps, ref: Ref<
248248
});
249249
}, []);
250250

251-
// @ts-ignore
252-
const tableWidthObserver = useRef(new ResizeObserver(updateTableClientWidth));
253-
254251
useEffect(() => {
255-
tableWidthObserver.current.observe(tableRef.current);
252+
// @ts-ignore
253+
const tableWidthObserver = new ResizeObserver(updateTableClientWidth);
254+
tableWidthObserver.observe(tableRef.current);
256255
return () => {
257-
tableWidthObserver.current.disconnect();
256+
tableWidthObserver.disconnect();
258257
};
259-
}, [tableWidthObserver.current, tableRef.current]);
258+
}, [updateTableClientWidth]);
260259

261260
useEffect(() => {
262261
dispatch({ type: 'SET_GROUP_BY', payload: groupBy });

0 commit comments

Comments
 (0)