diff --git a/packages/ui/src/hooks/use-filtered-list.tsx b/packages/ui/src/hooks/use-filtered-list.tsx index b6bd7d5c6..1b3be4b4c 100644 --- a/packages/ui/src/hooks/use-filtered-list.tsx +++ b/packages/ui/src/hooks/use-filtered-list.tsx @@ -22,18 +22,10 @@ export function useFilteredList(props: FilteredListProps) { const empty: Group[] = [] const [grouped, { refetch }] = createResource( - () => { - // When items is a function (not async filter function), call it to track changes - const itemsValue = - typeof props.items === "function" - ? (props.items as () => T[])() // Call synchronous function to track it - : props.items - - return { - filter: store.filter, - items: itemsValue, - } - }, + () => ({ + filter: store.filter, + items: typeof props.items === "function" ? undefined : props.items, + }), async ({ filter, items }) => { const needle = filter?.toLowerCase() const all = (items ?? (await (props.items as (filter: string) => T[] | Promise)(needle))) || []