From 71abdb2ee3f5bdb1e029c9f4266f4b797fa960f9 Mon Sep 17 00:00:00 2001
From: Sam Nystrom <sam@samnystrom.dev>
Date: Thu, 14 Mar 2024 00:10:12 +0000
Subject: fix: memoize stuff

---
 src/components/ButtonMenu.tsx | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

(limited to 'src/components/ButtonMenu.tsx')

diff --git a/src/components/ButtonMenu.tsx b/src/components/ButtonMenu.tsx
index 6a2b73e..f4427b3 100644
--- a/src/components/ButtonMenu.tsx
+++ b/src/components/ButtonMenu.tsx
@@ -1,5 +1,5 @@
 import type { ComponentChildren } from 'preact';
-import { useEffect, useRef, useId } from 'preact/hooks';
+import { useEffect, useCallback, useRef, useId } from 'preact/hooks';
 import { useSignal, batch } from '@preact/signals';
 import Button from './Button.tsx';
 import Menu from './Menu.tsx';
@@ -16,12 +16,12 @@ const ButtonMenu = ({ children, label }: ButtonMenuProps) => {
 	const x = useSignal(0);
 	const y = useSignal(0);
 
-	const updateRect = () => batch(() => {
+	const updateRect = useCallback(() => batch(() => {
 		const rect = ref.current?.getBoundingClientRect();
 		if (!rect) return;
 		x.value = rect.x;
 		y.value = rect.y + rect.height + 1;
-	});
+	}), []);
 	useEffect(updateRect, [ref.current]);
 
 	return (
-- 
cgit v1.2.3

