mirror of
https://github.com/nowcommunity/nowdatabase.git
synced 2026-10-12 19:13:52 +03:00
TableView: Fix re-render loop
This commit is contained in:
@@ -103,9 +103,15 @@ export const TableView = <T extends MRT_RowData>({
|
||||
const sortingToUrl = `sorting=${JSON.stringify(sorting)}`
|
||||
const paginationToUrl = `pagination=${JSON.stringify(pagination)}`
|
||||
setTableUrl(`${location.pathname}?&${columnFilterToUrl}&${sortingToUrl}&${paginationToUrl}`)
|
||||
setIdList(table.getPrePaginationRowModel().rows.map(row => row.original[idFieldName] as string))
|
||||
}, [columnFilters, sorting, pagination, location.pathname, selectorFn, setIdList, table, idFieldName, setTableUrl])
|
||||
|
||||
useEffect(() => {
|
||||
setIdList(table.getPrePaginationRowModel().rows.map(row => row.original[idFieldName] as string))
|
||||
|
||||
// Don't put setIdList in the dependency array: it will cause re-render loop.
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
}, [table, columnFilters, sorting])
|
||||
|
||||
if (!data) return <CircularProgress />
|
||||
|
||||
return <MaterialReactTable table={table} />
|
||||
|
||||
Reference in New Issue
Block a user