Skip to content

Commit c5320d7

Browse files
Avoid render-time refs in drawer height hook
Co-authored-by: Julius Marminge <juliusmarminge@users.noreply.github.com>
1 parent a1e7e1f commit c5320d7

1 file changed

Lines changed: 9 additions & 9 deletions

File tree

apps/web/src/components/ThreadTerminalDrawer.tsx

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -79,8 +79,13 @@ function useThreadDrawerHeight(threadId: ThreadId, height: number) {
7979
const drawerHeightRef = useRef(drawerHeight);
8080
const lastSyncedHeightRef = useRef(clampedSourceHeight);
8181

82-
drawerHeightRef.current = drawerHeight;
83-
lastSyncedHeightRef.current = clampedSourceHeight;
82+
useEffect(() => {
83+
drawerHeightRef.current = drawerHeight;
84+
}, [drawerHeight]);
85+
86+
useEffect(() => {
87+
lastSyncedHeightRef.current = clampedSourceHeight;
88+
}, [clampedSourceHeight]);
8489

8590
const setDrawerHeight = useCallback(
8691
(nextHeight: number) => {
@@ -918,13 +923,8 @@ export default function ThreadTerminalDrawer({
918923
keybindings,
919924
}: ThreadTerminalDrawerProps) {
920925
const [resizeEpoch, setResizeEpoch] = useState(0);
921-
const {
922-
drawerHeight,
923-
drawerHeightRef,
924-
lastSyncedHeightRef,
925-
setDrawerHeight,
926-
clearDrawerHeight,
927-
} = useThreadDrawerHeight(threadId, height);
926+
const { drawerHeight, drawerHeightRef, lastSyncedHeightRef, setDrawerHeight, clearDrawerHeight } =
927+
useThreadDrawerHeight(threadId, height);
928928
const resizeStateRef = useRef<{
929929
pointerId: number;
930930
startY: number;

0 commit comments

Comments
 (0)