Skip to content
Advertisement

React native flatlist return only one item from firestore

I’m new with react native. I’m using a flatlist to render data from firebase (v9).

Everything works well, there isn’t any error but, the list show only one item. After searching on differents topic, I think the problem is from the keyExtractor. But i don’t know how to solve it.

The Key Extractor from the code :

JavaScript

Here is the code :

JavaScript

Firestore :

enter image description here

The screen of the app :

enter image description here

Can you please help me ?? Thanks a lot !!

Advertisement

Answer

The recommended best practice is to run side effects like fetch data from server inside useEffect hook.

JavaScript
Advertisement