mirror of
https://github.com/gosticks/react-table.git
synced 2025-10-16 11:55:36 +00:00
fix: getRowID instead of getRowPathID
This commit is contained in:
parent
16c5512c4f
commit
f0293f5511
@ -103,13 +103,13 @@ The following options are supported via the main options object passed to `useTa
|
||||
- Defaults to `(row) => row.subRows || []`
|
||||
- Use this function to change how React Table detects subrows. You could even use this function to generate sub rows if you want.
|
||||
- By default, it will attempt to return the `subRows` property on the row, or an empty array if that is not found.
|
||||
- `getRowPathID: Function(row, relativeIndex) => string`
|
||||
- `getRowID: Function(row, relativeIndex) => string`
|
||||
- Use this function to change how React Table detects unique rows and also how it constructs each row's underlying `path` property.
|
||||
- Optional
|
||||
- Must be **memoized**
|
||||
- Defaults to `(row, relativeIndex) => relativeIndex`
|
||||
- Use this function to change how React Table constructs each row's underlying `path` property.
|
||||
- You may want to change this function if
|
||||
- By default, it will attempt to return the `subRows` property on the row, or an empty array if that is not found.
|
||||
- By default, it will use the `index` of the row within it's original array.
|
||||
- `debug: Bool`
|
||||
- Optional
|
||||
- A flag to turn on debug mode.
|
||||
|
||||
@ -20,7 +20,7 @@ const propTypes = {
|
||||
columns: PropTypes.arrayOf(PropTypes.object).isRequired,
|
||||
defaultColumn: PropTypes.object,
|
||||
getSubRows: PropTypes.func,
|
||||
getRowPathID: PropTypes.func,
|
||||
getRowID: PropTypes.func,
|
||||
debug: PropTypes.bool,
|
||||
}
|
||||
|
||||
@ -30,7 +30,7 @@ const renderErr =
|
||||
const defaultColumnInstance = {}
|
||||
|
||||
const defaultGetSubRows = (row, index) => row.subRows || []
|
||||
const defaultGetRowPathID = (row, index) => index
|
||||
const defaultGetRowID = (row, index) => index
|
||||
|
||||
export const useTable = (props, ...plugins) => {
|
||||
// Validate props
|
||||
@ -43,7 +43,7 @@ export const useTable = (props, ...plugins) => {
|
||||
columns: userColumns,
|
||||
defaultColumn = defaultColumnInstance,
|
||||
getSubRows = defaultGetSubRows,
|
||||
getRowPathID = defaultGetRowPathID,
|
||||
getRowID = defaultGetRowID,
|
||||
debug,
|
||||
} = props
|
||||
|
||||
@ -147,7 +147,7 @@ export const useTable = (props, ...plugins) => {
|
||||
// Keep the original reference around
|
||||
const original = originalRow
|
||||
|
||||
const rowID = getRowPathID(originalRow, i)
|
||||
const rowID = getRowID(originalRow, i)
|
||||
|
||||
// Make the new path for the row
|
||||
const path = [...parentPath, rowID]
|
||||
@ -199,7 +199,7 @@ export const useTable = (props, ...plugins) => {
|
||||
if (process.env.NODE_ENV === 'development' && debug)
|
||||
console.timeEnd('getAccessedRows')
|
||||
return [accessedData, rowPaths, flatRows]
|
||||
}, [debug, data, getRowPathID, getSubRows, flatColumns])
|
||||
}, [debug, data, getRowID, getSubRows, flatColumns])
|
||||
|
||||
instanceRef.current.rows = rows
|
||||
instanceRef.current.rowPaths = rowPaths
|
||||
|
||||
Loading…
Reference in New Issue
Block a user