mirror of
https://github.com/gosticks/react-table.git
synced 2026-10-03 22:36:55 +00:00
pass the instance with updated rows (#1714)
This commit is contained in:
committed by
Tanner Linsley
parent
9829927fab
commit
487abd2119
@@ -132,15 +132,6 @@ function useInstance(instance) {
|
||||
const preFilteredRows = rows
|
||||
const preFilteredFlatRows = flatRows
|
||||
|
||||
// Bypass any effects from firing when this changes
|
||||
const isMountedRef = React.useRef()
|
||||
safeUseLayoutEffect(() => {
|
||||
if (isMountedRef.current) {
|
||||
dispatch({ type: actions.resetFilters })
|
||||
}
|
||||
isMountedRef.current = true
|
||||
}, [dispatch, ...(getResetFiltersDeps ? getResetFiltersDeps(instance) : [])])
|
||||
|
||||
const setFilter = (columnId, filterValue) => {
|
||||
dispatch({ type: actions.setFilter, columnId, filterValue })
|
||||
}
|
||||
@@ -289,6 +280,26 @@ function useInstance(instance) {
|
||||
})
|
||||
}, [filteredRows, filters, flatColumns])
|
||||
|
||||
// Bypass any effects from firing when this changes
|
||||
const isMountedRef = React.useRef()
|
||||
safeUseLayoutEffect(() => {
|
||||
if (isMountedRef.current) {
|
||||
dispatch({ type: actions.resetFilters })
|
||||
}
|
||||
isMountedRef.current = true
|
||||
}, [
|
||||
dispatch,
|
||||
...(getResetFiltersDeps
|
||||
? getResetFiltersDeps({
|
||||
...instance,
|
||||
preFilteredRows,
|
||||
preFilteredFlatRows,
|
||||
rows: filteredRows,
|
||||
flatRows: filteredFlatRows,
|
||||
})
|
||||
: []),
|
||||
])
|
||||
|
||||
return {
|
||||
...instance,
|
||||
setFilter,
|
||||
|
||||
@@ -177,15 +177,6 @@ function useInstance(instance) {
|
||||
// Add custom hooks
|
||||
hooks.getSortByToggleProps = []
|
||||
|
||||
// Bypass any effects from firing when this changes
|
||||
const isMountedRef = React.useRef()
|
||||
safeUseLayoutEffect(() => {
|
||||
if (isMountedRef.current) {
|
||||
dispatch({ type: actions.resetSortBy })
|
||||
}
|
||||
isMountedRef.current = true
|
||||
}, [dispatch, ...(getResetSortByDeps ? getResetSortByDeps(instance) : [])])
|
||||
|
||||
// Updates sorting based on a columnId, desc flag and multi flag
|
||||
const toggleSortBy = (columnId, desc, multi) => {
|
||||
dispatch({ type: actions.toggleSortBy, columnId, desc, multi })
|
||||
@@ -345,6 +336,25 @@ function useInstance(instance) {
|
||||
userSortTypes,
|
||||
])
|
||||
|
||||
// Bypass any effects from firing when this changes
|
||||
const isMountedRef = React.useRef()
|
||||
safeUseLayoutEffect(() => {
|
||||
if (isMountedRef.current) {
|
||||
dispatch({ type: actions.resetSortBy })
|
||||
}
|
||||
isMountedRef.current = true
|
||||
}, [
|
||||
dispatch,
|
||||
...(getResetSortByDeps
|
||||
? getResetSortByDeps({
|
||||
...instance,
|
||||
toggleSortBy,
|
||||
rows: sortedRows,
|
||||
preSortedRows: rows,
|
||||
})
|
||||
: []),
|
||||
])
|
||||
|
||||
return {
|
||||
...instance,
|
||||
toggleSortBy,
|
||||
|
||||
Reference in New Issue
Block a user