I want to dispatch orderDetails from firestore. This code works when page load first time,but if i refresh page i got an error.
useEffect(() => {
const getUserOrders=()=>{
const shopdbRef=doc(db,"shopDB",user?.uid);
const userOrderRef=getDocs( collection(shopdbRef,"userOrderInfo"))
.then(response=>(
response.docs.map((doc)=>{
dispatch({
type:"ADD_TO_ORDERS",
item:{
id:doc.id,
data:doc.data()
}
})
})
)).catch(error=>{
console.log(error.message)
})
}
getUserOrders();
}, []);
error>>>>>>>>>>>>>
Warning: Can't perform a React state
update on an unmounted component.
This is a no-op, but it indicates a
memory leak in your application.
To fix, cancel all subscriptions
and asynchronous tasks in a useEffect
cleanup function.
I am new to react.js can anyone help me
as shown in the error what actually cleanup means,And how can i implement cleanup in my case.