You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
it could solve the infinite loop that's causing that useEffect to run continuously.
So it should look like this
useEffect(()=>{constfetchData=async()=>{awaitprojectFirestore.collection(currentUser.email).doc('records').collection('details').get().then((snapshot)=>{letrecords=snapshot.map((doc)=>{// use .map() instead of .forEach() to minimize mutationsletcurrentId=doc.id;letobject={ ...doc.data(),id: currentId};returnobject;});setRecords(records);// only runs if fetch runs successfully}).catch((err)=>console.log(err));};fetchData();},[currentUser]);
or
useEffect(()=>{constfetchData=async()=>{awaitprojectFirestore.collection(currentUser.email).doc('records').collection('details').get().then((snapshot)=>{letrecords=snapshot.map((doc)=>{// use .map() instead of forEach() to minimize mutationsletcurrentId=doc.id;letobject={ ...doc.data(),id: currentId};returnobject;});setRecords(records);// only runs if the fetch runs successfully}).catch((err)=>console.log(err));};if(records.length===0){// and add a conditionfetchData();}console.log(records);console.log(count);},[currentUser,count,records]);// leave them in
Also fun fact if you use async/await you can access variables similar to regular code i.e
functiontransformSnapshot(doc){letcurrentId=doc.id;letobject={ ...doc.data(),id: currentId};returnobject;}functionrequest(){letsnapshot=awaitprojectFirestore.collection(currentUser.email).doc('records').collection('details').get();// await until `.get()` is done executingreturnsnapshot.map(transformSnapshot);}
The text was updated successfully, but these errors were encountered:
If you take these two out:
recallr/src/components/Records.js
Lines 112 to 113 in 3841c59
and remove them here too:
recallr/src/components/Records.js
Line 117 in 3841c59
and move this line
recallr/src/components/Records.js
Line 111 in 3841c59
inside this function
recallr/src/components/Records.js
Line 103 in 3841c59
it could solve the infinite loop that's causing that
useEffect
to run continuously.So it should look like this
or
Also fun fact if you use async/await you can access variables similar to regular code i.e
The text was updated successfully, but these errors were encountered: