From 1bf8fb1d980ee19fa6f448c098bdf1e87ac2f6e9 Mon Sep 17 00:00:00 2001 From: Alexander Bespoyasov Date: Fri, 21 Jan 2022 17:32:13 +0100 Subject: [PATCH] Move `products` definition closer to where it's used --- src/App.js | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/App.js b/src/App.js index 909c295..818ff64 100644 --- a/src/App.js +++ b/src/App.js @@ -51,14 +51,11 @@ function Coupon({ onEnter }) { } function App() { - let products; const [status, setStatus] = useState("idle"); const [error, setError] = useState(null); const { user } = useUserStore(); const { cart } = useCart(); - products = cart.products; - async function handleSubmitByValidatingDataAndCreatingOrder(e) { e.preventDefault(); setStatus("loading"); @@ -79,6 +76,7 @@ function App() { } const _userId = user.name; + const products = cart.products; let price = 0; for (const p_i in products) { price += products[p_i].price * products[p_i].count;