useFilter

A custom React hook that manages filtering, searching, pagination, and sorting.

# Basic Usage


import { useFilter } from 'blackborne/hooks';

const { filter } = useFilter({
  search: 'example',
  page: { number: 2, size: 25 },
  sort: '-createdAt'
});

useFilter Hook Return

PropTypeDescription
filterObjectContains the current filter state.
setSortFunctionUpdates the sorting criteria. Parameter: sort (string) - The sorting key.
setDateFunctionSets the start and end date filters. Parameters: start (string | Date) - Start date, end (string | Date) - End date.
setPageFunctionUpdates the page number. Parameter: page (number) - The new page number.
setSearchFunctionUpdates the search keyword. Parameter: search (string) - The search term.
setResetFunctionResets the filter to the initial values.
setFilterFunctionReplaces the filter state with a new object. Parameter: newFilter (Object) - The new filter state.