Skip to content

Commit 250f0b9

Browse files
committed
#4020 infinitely cleaner tasklistcontent refactor to remove useref
1 parent 0eef5c7 commit 250f0b9

1 file changed

Lines changed: 4 additions & 7 deletions

File tree

src/frontend/src/pages/ProjectDetailPage/ProjectViewContainer/TaskList/v2/TaskListContent.tsx

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { DragDropContext, OnDragEndResponder, OnDragStartResponder } from '@hello-pangea/dnd';
22
import { Box } from '@mui/material';
3-
import { useCallback, useRef, useState } from 'react';
3+
import { useCallback, useState } from 'react';
44
import { Project, Task, TaskWithIndex } from 'shared';
55
import { getTasksByStatus, statuses, TasksByStatus } from '.';
66
import { useSetTaskStatus } from '../../../../../hooks/tasks.hooks';
@@ -19,15 +19,12 @@ export const TaskListContent = ({ project }: TaskListProps) => {
1919

2020
const toast = useToast();
2121

22-
// ref to mapping of each column's status to its measured height, partial because heights may not exist
23-
const columnHeightsRef = useRef<Partial<Record<Task['status'], number>>>({});
24-
const [equalizedHeight, setEqualizedHeight] = useState(0);
2522
const [isDragging, setIsDragging] = useState(false);
23+
const [columnHeights, setColumnHeights] = useState<Partial<Record<Task['status'], number>>>({});
24+
const equalizedHeight = Math.max(...(Object.values(columnHeights) as number[]));
2625

2726
const onHeightChange = useCallback((status: Task['status'], height: number) => {
28-
columnHeightsRef.current[status] = height;
29-
const max = Math.max(...(Object.values(columnHeightsRef.current) as number[]));
30-
setEqualizedHeight(max);
27+
setColumnHeights((prev) => ({ ...prev, [status]: height }));
3128
}, []);
3229

3330
const onDeleteTask = (taskId: string) => {

0 commit comments

Comments
 (0)