fix(utils/example): fixed ensurePluginOrder utility, perf/debug updates

This commit is contained in:
tannerlinsley 2019-08-05 08:59:35 -06:00
parent fd0fe43ad9
commit 2b30c84abc
3 changed files with 13 additions and 6 deletions

View File

@ -43,7 +43,6 @@ function Table({ columns, data }) {
columns,
data,
defaultColumn,
debug: true,
},
useSortBy
)

View File

@ -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]

View File

@ -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!`
)