I'm just trying to render my Flalist with my state (ListOfProducts), which is an array of arrays of FirestoreDocumentSnapshot that looks like this:
But nothing is rendering. That's my code:
return ( <View> <TouchableOpacity onPress={() => console.log(listOfProducts)}> <Text>Log ListOfProducts</Text> </TouchableOpacity> <View style=> <FlatList style= data={listOfProducts} keyExtractor={(item, index) => { item[index].id; }} renderItem={({item}) => ( <View style=> <Text style=> MON CHIBROS </Text> </View> )} /> </View> </View> ); Getting my data from Firestore like this:
useEffect(() => { const unsubscribe = getUserLocation() .then((location) => getProducts(location.coords)) .catch((e) => { throw new Error(e.message); }); const getProducts = async (coords) => { console.log('getProducts'); let nearbyGeocollections = await geocollection .limit(10) .near({ center: new firestore.GeoPoint(coords.latitude, coords.longitude), radius: 50, }) .get(); let nearbyUsers = []; await nearbyGeocollections.forEach((geo) => { if (geo.id !== user.uid) { firestore() .collection('PRODUCTS') .doc(geo.id) .collection('USER_PRODUCTS') .onSnapshot((product) => { nearbyUsers.push(product.docs); }); } }); setLoading(false); setListOfProducts(nearbyUsers); }; return () => { unsubscribe; setListOfProducts([]); }; }, []); If someone can point me out what are my mistakes, I would greatly appreciate.
https://stackoverflow.com/questions/66384510/flatlist-not-rendering-with-array-of-arrays-of-firestore-snapshots February 26, 2021 at 06:55PM
没有评论:
发表评论