How to Add loadmore in react native flatlist
get result from redux
SearchScreen
const listing= useSelector((state) => state.adData.data);
<FlatList
showsVerticalScrollIndicator={false}
data={listings}
keyExtractor={keyExtractor}
removeClippedSubviews={true}
onEndReached={loadMore}
onEndReachedThreshold={0.8}
windowSize={15}
getItemLayout={getItemLayout}
renderItem={renderItem}
/>
const loadMore = async () => {
setpageCurrent((page) => page + 1);
};
I'm try data concat return { ...state, data: [...state.concat(payload)], 'loading': false };
Not working correctly
Reducer
export default function productReducer(
state = initState,
{ type, payload, error }
) {
switch (type) {
// Get list products
case Actions.GET_ADS:
return { ...state, loading: true };
case Actions.GET_ADS_SUCCESS:
return {...state, data : payload,'loading': false};
default:
return state;
}
Saga
function* fetchListingsSaga({ page }) {
try {
const data = yield call(getListings, { page });
yield put({ type: Actions.GET_ADS_SUCCESS, payload: data.data.response });
} catch (e) {
yield put({ type: Actions.GET_PRODUCT_ATTRIBUTE_ERROR, error: e });
}
}