Skip to content

Commit

Permalink
Fix Rerendering Issue (#60)
Browse files Browse the repository at this point in the history
  • Loading branch information
luisaugusto committed Apr 1, 2024
1 parent 20a30c4 commit 8cd419f
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/api/firebase.js
Original file line number Diff line number Diff line change
Expand Up @@ -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(() => {
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 8cd419f

Please sign in to comment.