From b78b081d29b9ba207148cff1594a5b39fadfed88 Mon Sep 17 00:00:00 2001 From: Unchained Date: Sat, 28 Mar 2026 18:41:36 +0200 Subject: [PATCH] fix: use ref instead of state for initialization flag to prevent dependency array size change --- src/components/cart/CartDrawer.tsx | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/components/cart/CartDrawer.tsx b/src/components/cart/CartDrawer.tsx index 705b6f8..85cb1a3 100644 --- a/src/components/cart/CartDrawer.tsx +++ b/src/components/cart/CartDrawer.tsx @@ -30,16 +30,16 @@ export default function CartDrawer() { const lines = getLines(); const total = getTotal(); const lineCount = getLineCount(); - const [initialized, setInitialized] = useState(false); + const initializedRef = useRef(false); useEffect(() => { - if (!initialized && locale) { + if (!initializedRef.current && locale) { // Set language code before initializing checkout useSaleorCheckoutStore.getState().setLanguageCode(locale); initCheckout(); - setInitialized(true); + initializedRef.current = true; } - }, [initialized, locale]); + }, [locale]); useEffect(() => { if (isOpen) {