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:
Aaron Corley
2019-12-19 15:21:27 -07:00
committed by Tanner Linsley
parent 94a9b49187
commit 45e5bed468
3 changed files with 14 additions and 11 deletions
+6 -6
View File
@@ -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,
+2 -2
View File
@@ -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
+6 -3
View File
@@ -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