diff --git a/examples/sorting-client-side/src/App.js b/examples/sorting-client-side/src/App.js index 13ec4bd..678245a 100644 --- a/examples/sorting-client-side/src/App.js +++ b/examples/sorting-client-side/src/App.js @@ -43,7 +43,6 @@ function Table({ columns, data }) { columns, data, defaultColumn, - debug: true, }, useSortBy ) diff --git a/src/plugin-hooks/useSortBy.js b/src/plugin-hooks/useSortBy.js index cc0aa7b..370b2a0 100755 --- a/src/plugin-hooks/useSortBy.js +++ b/src/plugin-hooks/useSortBy.js @@ -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] diff --git a/src/utils.js b/src/utils.js index 6173ab9..51ab106 100755 --- a/src/utils.js +++ b/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!` )