So. I get clients from context as initialState and the code below is from my listing component (listClients.js or smth) . I update the context with the data fetched from firebase. Everything works fine actully with using empty array as dependency. I get my final array listed on my list component.. But eslint is still saying me that I should add "clientsRef" and "updateClients" into dependency but this causes an infinite loop. So what should I do with that? Close my eyes to this warning?
const { clients, removeClient, updateClients } = useContext(ClientsContext);
const collection = 'clients';
const clientsRef = firestore.collection('clients').orderBy('createdAt', 'desc');
useEffect(() => {
const unsubscribeFromSnapshot = clientsRef.onSnapshot(async snapshot => {
const clientsMap = convertSnapshotToMap(snapshot);
updateClients(clientsMap);
});
return () => {
unsubscribeFromSnapshot();
}
}, []);