hi im try to filter my flatlist data from api…but the data alawys return empty…but when im console.log it has data…
here is my code
const typeMeter = route.params;
const {data:listBuilding,error,errorMsg,loading,request:loadBuilding} = useApi(listingApi.getListingsBuildingByRole);
const [refreshing, setRefreshing] = useState(false);
const [search, setSearch] = useState('');
const [filter, setFilter] = useState([]);
useEffect(()=> {
loadBuilding(typeMeter);
},[])
const searchFilter = (text)=> {
if(text){
const newData = listBuilding.list.filter((item)=>{
const itemList = item.bld_name ? item.bld_name.toUpperCase():'';
const itemSearch = text.toUpperCase();
return itemList.indexOf(itemSearch) > -1;
})
setFilter(newData);
setSearch(text);
}else{
setFilter(listBuilding.list);
setSearch('');
}
}