From 781bec762177a66626b393fb34b8da7a769c2234 Mon Sep 17 00:00:00 2001 From: Luis Augusto Date: Mon, 1 Apr 2024 14:37:18 -0700 Subject: [PATCH] Fix Rerendering Issue --- src/api/firebase.js | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/api/firebase.js b/src/api/firebase.js index ec20c6f..a9f221e 100644 --- a/src/api/firebase.js +++ b/src/api/firebase.js @@ -57,10 +57,11 @@ export function useShoppingLists(userId, userEmail) { * @param {string | null} listPath * @see https://firebase.google.com/docs/firestore/query-data/listen */ +// Start with an empty array for our data. +/** @type {import('firebase/firestore').DocumentData[]} */ +const initialState = []; + export function useShoppingListData(listPath) { - // Start with an empty array for our data. - /** @type {import('firebase/firestore').DocumentData[]} */ - const initialState = []; const [data, setData] = useState(initialState); useEffect(() => { @@ -88,7 +89,7 @@ export function useShoppingListData(listPath) { // Update our React state with the new data. setData(nextData); }); - }, [initialState, listPath]); + }, [listPath]); // Return the data so it can be used by our React components. return data;