I am trying to access updated value from firebase in every flatlist rendered component using there unique id.
Steps:
- I call the api to get the list of data.
- Once the complete list rendered into the flatlist.
- Then I add the firebase listener in every rendered component to get the updated value of score.
But the problem is that listers works only on last element of list.
and i am using hooks functional component
Here is the need full code please check :
let homeData=firestore().collection("firestore_match_odds_change")
useEffect(()=>{
updateOdd(data.uid);
},[])
updateOdd = (matchId)=> {
homeData.doc(matchId)
.onSnapshot((dataItem) => {
if (dataItem._data !== undefined) {
console.log("print updated match id", dataItem);
}
});
}
See In this screenshot only last render element got the data from firebase not others.
Thank you.
question from:
https://stackoverflow.com/questions/65920455/how-to-call-firebase-listener-to-each-flatlist-rendered-component-using-hooks-in 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…