I'm using ReactJS and Google FireStore to create a simple stock portfolio tracking app. How can I access database functions from within useEffect without triggering the warning "React Hook has a missing dependency"? I've tried playing around a bit with useCallback, but no success so far. Or is it ok to ignore these warnings?
var db = firebase.firestore();
useEffect(() => {
//get user's cost averages from db
if (props.userStatus) {
db.collection("users")
.doc(props.userStatus)
.get()
.then((doc) => {
if (doc.exists) {
if (doc.data().portfolio) {
setCostAverages(doc.data().portfolio);
}
}
});
}
}, [props.userStatus]);
Warning msg: "React Hook useEffect has missing dependency 'db'
package.json?