i have a parent component returning a flatlist , renderItem of flatlist returns child component , that child component makes a an api call so the parent component should wait promise of every child. I have tried to handle that by creating a promise inside useeffect but this did not work , could you help ,here is my code this is from child component:
useEffect(() => {
const promises = async () => {
return await Promise.all([
userFollowers(link)
.then((datax) => {
setUserFollower(datax);
dispatch({
type: 'GET_FOLLOWING',
payload: datax,
});
})
.catch((e) => e),
userFollowing(item.item.followers_url)
.then((datax) => {
setFlwCounter(datax);
dispatch({
type: 'GET_FOLLOWERS',
payload: datax,
});
})
.catch((e) => e),
]);
};
return () => promises();
}, [item, userFollower, flwCounter]);
the error it says :
Please report: Excessive number of pending callbacks: 501.
parent component here 's from where I call child component
const renderItems = (item) => {
return <UserItem item={item} />;
};