Skip to content

Commit 32d1fbd

Browse files
author
ben.durrant
committed
ensure action before trying to match
1 parent efc38c8 commit 32d1fbd

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

packages/toolkit/src/dynamicMiddleware/index.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import type {
55
MiddlewareAPI,
66
} from 'redux'
77
import { compose } from 'redux'
8-
import { createAction } from '../createAction'
8+
import { createAction, isAction } from '../createAction'
99
import { nanoid } from '../nanoid'
1010
import { find } from '../utils'
1111
import type {
@@ -93,6 +93,7 @@ export const createDynamicMiddleware = <
9393
const middleware: DynamicMiddleware<State, Dispatch> =
9494
(api) => (next) => (action) => {
9595
if (
96+
isAction(action) &&
9697
withMiddleware.match(action) &&
9798
action.meta.instanceId === instanceId
9899
) {

packages/toolkit/src/dynamicMiddleware/tests/index.test.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import type { Middleware } from 'redux'
22
import { createDynamicMiddleware } from '../index'
33
import { configureStore } from '../../configureStore'
44
import type { BaseActionCreator, PayloadAction } from '../../createAction'
5+
import { isAction } from '../../createAction'
56
import { createAction } from '../../createAction'
67

78
export interface ProbeMiddleware
@@ -22,7 +23,11 @@ export const makeProbeableMiddleware =
2223
(api) =>
2324
(next) =>
2425
(action) => {
25-
if (probeMiddleware.match(action) && action.payload === id) {
26+
if (
27+
isAction(action) &&
28+
probeMiddleware.match(action) &&
29+
action.payload === id
30+
) {
2631
return id
2732
}
2833
return next(action)

0 commit comments

Comments
 (0)