MCPcopy Create free account
hub / github.com/adobe/react-spectrum / useLibrarySections

Function useLibrarySections

packages/dev/s2-docs/src/searchUtils.tsx:302–315  ·  view source on GitHub ↗
(pages: Page[], library: Library, searchValue: string)

Source from the content-addressed store, hash-verified

300 * Hook to build and manage sections for a library with search filtering.
301 */
302export function useLibrarySections(pages: Page[], library: Library, searchValue: string) {
303 const sections = useMemo(() => buildSectionsFromPages(pages, library), [pages, library]);
304
305 const filteredSections = useMemo(
306 () => filterSections(sections, searchValue),
307 [sections, searchValue]
308 );
309
310 const getSectionNames = useCallback(() => {
311 return sections.map(s => s.name);
312 }, [sections]);
313
314 return {sections, filteredSections, getSectionNames};
315}
316
317/**
318 * Creates search options for filtering/sorting Page objects directly.

Callers 1

useSearchMenuStateFunction · 0.85

Calls 2

buildSectionsFromPagesFunction · 0.85
filterSectionsFunction · 0.85

Tested by

no test coverage detected