mirror of
https://github.com/gosticks/react-table.git
synced 2026-08-12 21:10:24 +00:00
misc fixes for useGlobalFilter (#1795)
* docs(useglobalfilter.md): corrected documentation for setGlobalFilter * fix(useglobalfilter.js): wrapped setGlobalFilter in useCallback Wrapped setGlobalFilter in useCallback for identity stability.
This commit is contained in:
committed by
Tanner Linsley
parent
94a9b49187
commit
45e5bed468
+6
-6
@@ -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,
|
||||
|
||||
@@ -43,8 +43,8 @@ The following values are provided to the table `instance`:
|
||||
- `preGlobalFilteredRows: Array<Row>`
|
||||
- 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
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user