mirror of
https://github.com/gosticks/react-table.git
synced 2026-08-07 09:59:05 +00:00
Fix action type detection
This commit is contained in:
+3
-1
@@ -1,6 +1,7 @@
|
||||
const actions = {}
|
||||
const types = {}
|
||||
|
||||
export { actions }
|
||||
export { actions, types }
|
||||
|
||||
export const addActions = (...acts) => {
|
||||
acts.forEach(action => {
|
||||
@@ -14,5 +15,6 @@ export const addActions = (...acts) => {
|
||||
// other than importing `{ actions } from 'react-table'`
|
||||
// and referencing an action via `actions[actionName]`
|
||||
actions[action] = `React Table Action: ${action}`
|
||||
types[actions[action]] = true
|
||||
})
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import React from 'react'
|
||||
//
|
||||
import { actions } from '../actions'
|
||||
import { types } from '../actions'
|
||||
|
||||
export const defaultState = {}
|
||||
|
||||
@@ -32,12 +32,11 @@ export const useTableState = (
|
||||
const reducedSetState = React.useCallback(
|
||||
(updater, type) => {
|
||||
return setState(old => {
|
||||
if (!actions[type]) {
|
||||
if (!types[type]) {
|
||||
console.info({
|
||||
currentState: old,
|
||||
stateUpdaterFn: updater,
|
||||
actionType: type,
|
||||
supportedActions: actions,
|
||||
currentState: old,
|
||||
})
|
||||
throw new Error('Detected an unknown table action! (Details Above)')
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user