diff --git a/.size-snapshot.json b/.size-snapshot.json index 09ef870..403285a 100644 --- a/.size-snapshot.json +++ b/.size-snapshot.json @@ -1,13 +1,13 @@ { "dist/index.js": { - "bundled": 112721, - "minified": 52301, - "gzipped": 13754 + "bundled": 113159, + "minified": 52747, + "gzipped": 13786 }, "dist/index.es.js": { - "bundled": 111784, - "minified": 51465, - "gzipped": 13587, + "bundled": 111809, + "minified": 51501, + "gzipped": 13598, "treeshaked": { "rollup": { "code": 80, diff --git a/docs/api/useGlobalFilter.md b/docs/api/useGlobalFilter.md index 059a82c..6aabc68 100644 --- a/docs/api/useGlobalFilter.md +++ b/docs/api/useGlobalFilter.md @@ -43,8 +43,8 @@ The following values are provided to the table `instance`: - `preGlobalFilteredRows: Array` - The array of rows **used right before filtering**. - Among many other use-cases, these rows are directly useful for building option lists in filters, since the resulting filtered `rows` do not contain every possible option. -- `setGlobalFilter: Function(columnId, filterValue) => void` - - An instance-level function used to update the filter value for a specific column. +- `setGlobalFilter: Function(filterValue) => void` + - An instance-level function used to update the global filter value. ### Example diff --git a/src/plugin-hooks/useGlobalFilter.js b/src/plugin-hooks/useGlobalFilter.js index 3e3d33b..a58b036 100644 --- a/src/plugin-hooks/useGlobalFilter.js +++ b/src/plugin-hooks/useGlobalFilter.js @@ -75,9 +75,12 @@ function useInstance(instance) { 'useExpanded', ]) - const setGlobalFilter = filterValue => { - dispatch({ type: actions.setGlobalFilter, filterValue }) - } + const setGlobalFilter = React.useCallback( + filterValue => { + dispatch({ type: actions.setGlobalFilter, filterValue }) + }, + [dispatch] + ) // TODO: Create a filter cache for incremental high speed multi-filtering // This gets pretty complicated pretty fast, since you have to maintain a