Gives components the categories of one kind, of those CategoriesProvider
loads once for the whole app.
f
useCategories(kind: CategoryKind): KindCategories
Returns the categories of kind, dump or playlist, and a function that
refetches them. Under no CategoriesProvider, the list is empty.
I
KindCategories
Returned by useCategories: one kind's categories.
-
byId: Map<string, Category>
Resolves a dump's or playlist's
categoryIdsto its category chips. -
categories: Category[]
The categories of the kind, by position then slug.
-
isLoaded: boolean
Whether the first fetch has ended. It is also true after a network error, with no categories.
-
refresh: () => Promise<void>
Refetches both kinds. The category manager calls it after each change.
Usage
import * as mod from "src/hooks/category/useCategories.ts";