So I am new to React Native and I am building this app with redux and react-navigation. Here's the problem:
I am fetching records from API, things were working fine. While I fetch records there's a Loading icon then after that the Listview display the records, then when there are no records I display a No record found. Text. Then suddenly the records just stop displaying, the Loading icon just keep on displaying when there are records but when there's no record the Text displays.
What could have caused this bug? I am using Expo so I print to console the fetched records and there are records. Also after the data get fetched I put a console.log in render function and it is called which means it just don't render the Listview.
Thanks in advance!
UPDATE
So i've used FlatList as suggested below and i've found that the item passed from FlatList is undefined which is again strange cause when I print the data I passed on the list it has contents. Here is my current code:
MyFlatlist
return <FlatList
data={data} //an array of objects
renderItem={this._renderItem} //console prints undefined
/>
//I also tried
return <FlatList
data={data} //an array of objects
renderItem={({item}) => this._renderItem(item)} //I think this doesn't call the method cause it doesn't print anything on the console.
/>
MyRenderItem
_renderItem = ({item}) => {
console.log(item)
}
FINAL UPDATE
So there were two factors that caused this problem, first the API where I get my data changed which result to fields that I access in my view isn't there anymore, React Native see this as error and as a result the rendering stops without an error msg which is why it is hard to detect. Second, when I used FlatList, the per item sent to the renderItem function is also under an object which has a property item that contains the actual data so the rendering stops again.
This is fixed now as far as my setup is concerned. Thanks for all your help!