Options
Here are the options the you can provide to configure the catalog.
createCatalog<City, Filters>({
/// options
});
key
string
A unique key that allows for a safe storage for multiple catalogs in SSR. Normally, the state is stored in a standard ref
, which will be lost in the SSR hydration process. But with a key, the state is stored using useRef
from @dija/tohama-state
.
mode
"pages" | "infinite"
In pages
mode, it will only display the current page's entries.
In infinite
mode, it will display all entries sorted by the page number.
layout
"grid" | "table" | "list"
This allows you to display the entries based on user preference.
cache
boolean
This is useful in pages
mode. It allows storing the results of a page and retrieve it when the page is revisited again.
aggregates
UseCatalogAggregatesOptional<F>
Use it to provide the initial aggregates
. For example, to initialize the catalog on the second page.
onFetch
(required)
(aggregates: UseCatalogAggregates<F>) => UseCatalogResponse<T, F> | Promise<UseCatalogResponse<T, F>>
Learn more above.
getEntryKey
This is used when selection
is enabled. It should return a unique value such as the entry id
.