Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Rerendering Issue #60

Merged
merged 1 commit into from
Apr 1, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 = [];
luisaugusto marked this conversation as resolved.
Show resolved Hide resolved

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
Loading