const filteredSearchData = () => {
const fetchedAllStoreArray = data?.data.data.filter(
({ 업종 }: any) => !filterString.includes(업종)
);
const fetchedAllStore = fetchedAllStoreArray.map((storeArray: any) =>
Object.values(storeArray)
);
const stringifyAllStore = fetchedAllStore.filter((store: any) =>
store.join(',').includes(searchInputVal)
);
return stringifyAllStore;
};
...
{filteredSearchData().map((store: any) => <></>}
...
복잡한 함수이기에 useCallback으로 덮어주기
const filteredSearchData = useCallback(() => {
const fetchedAllStoreArray = data?.data.data.filter(
({ 업종 }: any) => !filterString.includes(업종)
);
const fetchedAllStore = fetchedAllStoreArray.map((storeArray: any) =>
Object.values(storeArray)
);
const stringifyAllStore = fetchedAllStore.filter((store: any) =>
store.join(',').includes(searchInputVal)
);
return stringifyAllStore;
}, [data?.data.data, searchInputVal]);