Compare commits

...
Author SHA1 Message Date
tannerlinsley 8776d78edb v7.0.0-alpha.29 2019-08-26 09:38:53 -06:00
tannerlinsley f0293f5511 fix: getRowID instead of getRowPathID 2019-08-26 09:38:14 -06:00
3 changed files with 9 additions and 9 deletions
+3 -3
View File
@@ -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.
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "react-table",
"version": "7.0.0-alpha.28",
"version": "7.0.0-alpha.29",
"description": "A fast, lightweight, opinionated table and datagrid built on React",
"license": "MIT",
"homepage": "https://github.com/tannerlinsley/react-table#readme",
+5 -5
View File
@@ -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