mirror of
https://github.com/gosticks/react-table.git
synced 2025-10-16 11:55:36 +00:00
fix(utils/example): fixed ensurePluginOrder utility, perf/debug updates
This commit is contained in:
parent
fd0fe43ad9
commit
2b30c84abc
@ -43,7 +43,6 @@ function Table({ columns, data }) {
|
||||
columns,
|
||||
data,
|
||||
defaultColumn,
|
||||
debug: true,
|
||||
},
|
||||
useSortBy
|
||||
)
|
||||
|
||||
@ -269,12 +269,12 @@ function useMain(instance) {
|
||||
row.subRows = sortData(row.subRows)
|
||||
})
|
||||
|
||||
if (process.env.NODE_ENV === 'development' && debug)
|
||||
console.timeEnd('getSortedRows')
|
||||
|
||||
return sortedData
|
||||
}
|
||||
|
||||
if (process.env.NODE_ENV === 'development' && debug)
|
||||
console.timeEnd('getSortedRows')
|
||||
|
||||
return sortData(rows)
|
||||
},
|
||||
[manualSorting, sortBy, debug, columns, rows, orderByFn, userSortTypes]
|
||||
|
||||
12
src/utils.js
12
src/utils.js
@ -315,11 +315,19 @@ export function ensurePluginOrder(plugins, befores, pluginName, afters) {
|
||||
plugin => plugin.pluginName === pluginName
|
||||
)
|
||||
|
||||
if (pluginIndex === -1) {
|
||||
throw new Error(`The plugin ${pluginName} was not found in the plugin list!
|
||||
This usually means you need to need to name your plugin hook by setting the 'pluginName' property of the hook function, eg:
|
||||
|
||||
${pluginName}.pluginName = '${pluginName}'
|
||||
`)
|
||||
}
|
||||
|
||||
befores.forEach(before => {
|
||||
const beforeIndex = plugins.findIndex(
|
||||
plugin => plugin.pluginName === before
|
||||
)
|
||||
if (beforeIndex > pluginIndex) {
|
||||
if (beforeIndex > -1 && beforeIndex > pluginIndex) {
|
||||
throw new Error(
|
||||
`React Table: The ${pluginName} plugin hook must be placed after the ${before} plugin hook!`
|
||||
)
|
||||
@ -328,7 +336,7 @@ export function ensurePluginOrder(plugins, befores, pluginName, afters) {
|
||||
|
||||
afters.forEach(after => {
|
||||
const afterIndex = plugins.findIndex(plugin => plugin.pluginName === after)
|
||||
if (afterIndex < pluginIndex) {
|
||||
if (afterIndex > -1 && afterIndex < pluginIndex) {
|
||||
throw new Error(
|
||||
`React Table: The ${pluginName} plugin hook must be placed before the ${after} plugin hook!`
|
||||
)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user