Skip to content

useTableFilterState

@astryxdesign/core v0.7.1 · useTableFilterState

Parameters ​

useTableFilterState() takes one optional argument, in either of two shapes.

NameTypeDefaultDescription
initialTableFilterState{}The initial filter map itself. It is shallow copied, so the object you pass is never written to.
initial.initialStateTableFilterState{}The same map behind an initialState key: useTableFilterState({ initialState }). A filter value is never an object, so a key named initialState with an object value can only be this form.

Returns ​

NameTypeDescription
filtersRef<TableFilterState>The live filter map. Read filters.value for the current state.
onFilterChange(key: string, value: TableFilterValue | null) => voidSets or clears one field. The map is replaced with a new object, so a getter over it stays in sync.
clearAll() => voidEmpties the map. Every filter turns off at once.

TableFilterState ​

NameTypeDescription
[fieldKey]TableFilterValueField key to filter value. TableFilterValue is string | number | string[].