Skip to content

Commit

Permalink
Fix maximum update depth exceeded
Browse files Browse the repository at this point in the history
  • Loading branch information
Minnowo authored and jmattheis committed Sep 28, 2024
1 parent 0202c1e commit 3ea82aa
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions ui/src/timespan/DoneTrackers.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ export const DoneTrackers: React.FC<DoneTrackersProps> = ({addTagsToTracker}) =>
timeSpans={timeSpans}
addTagsToTracker={addTagsToTracker}
setHeight={setHeights}
height={heights[key] || 500}
/>
);
})}
Expand All @@ -125,14 +126,16 @@ export const DoneTrackers: React.FC<DoneTrackersProps> = ({addTagsToTracker}) =>
const DatedTimeSpans: React.FC<{
name: string;
setHeight: (cb: (height: Record<string, number>) => Record<string, number>) => void;
height: number;
timeSpans: TimeSpanProps[];
} & DoneTrackersProps> = ({name, timeSpans, addTagsToTracker, setHeight}) => {
} & DoneTrackersProps> = ({name, timeSpans, addTagsToTracker, setHeight, height}) => {
const ref = React.useRef<HTMLDivElement | null>();
React.useEffect(() => {
if (ref.current) {
setHeight((old) => ({...old, [name]: ref.current!.getBoundingClientRect().height}));
const currentHeight = ref.current && ref.current.getBoundingClientRect().height;
if (currentHeight != null && currentHeight !== height) {
setHeight((old) => ({...old, [name]: currentHeight}));
}
}, [ref, name, setHeight]);
}, [ref, name, setHeight, height]);
return (
<div key={name} ref={(r) => (ref.current = r)}>
<Typography key={name} align="center" variant={'h5'}>
Expand Down

0 comments on commit 3ea82aa

Please sign in to comment.