I have a large list approximately 250+ Items that is inserted in the Flatlist
on render it is very slow but i think it is manageable. My real problem is about the real time listener which is very active and always updating the state of the list. maybe 1 item per 100ms. after some time listening to the data. I got this warning Excessive number of pending callbacks: 501
and the application become more delay to the touch response. how can i optimize it? is there a better way to load a large list?
Here is my sample code:
import React, { FunctionComponent, useState, useEffect, useRef } from "react";
import { View } from "react-native"
const Sample : FunctionComponent<any> = props => {
// contains 250+ items
const [list, setList] = useState<any[]>();
useEffect(() => {
//updates the list everytime it catches a data
myListener((somevalue) => setList(somevalue))
};
// very slow
render(){
<FlatList
data=[list]
renderItem={renderItem}
getItemLayout={getItemLayout}
initialNumToRender={initialItemRender}
maxToRenderPerBatch={5}
keyExtractor={(item, index) => item.value}
/>
}
}
This is only my sample code. if you have an idea on better way optimizing the list. i'll appreciate it