Skip to content

Commit 75c7b89

Browse files
committed
Ignore serializability of meta.args by default
1 parent 1279c3f commit 75c7b89

File tree

2 files changed

+24
-1
lines changed

2 files changed

+24
-1
lines changed

src/serializableStateInvariantMiddleware.test.ts

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -385,4 +385,27 @@ describe('serializableStateInvariantMiddleware', () => {
385385
(See https://redux.js.org/faq/organizing-state#can-i-put-functions-promises-or-other-non-serializable-items-in-my-store-state)"
386386
`)
387387
})
388+
389+
it('should not check serializability for meta.args by default', () => {
390+
const badValue = new Map()
391+
392+
const reducer: Reducer = (state = 42, action) => {
393+
return state
394+
}
395+
396+
const serializableStateInvariantMiddleware = createSerializableStateInvariantMiddleware()
397+
398+
const store = configureStore({
399+
reducer: {
400+
testSlice: reducer
401+
},
402+
middleware: [serializableStateInvariantMiddleware]
403+
})
404+
405+
store.dispatch({ type: 'testAction', meta: { args: { badValue } } })
406+
407+
const { log } = getLog()
408+
expect(log).toBe('')
409+
const q = 42
410+
})
388411
})

src/serializableStateInvariantMiddleware.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ export function findNonSerializableValue(
3535
path: ReadonlyArray<string> = [],
3636
isSerializable: (value: unknown) => boolean = isPlain,
3737
getEntries?: (value: unknown) => [string, any][],
38-
ignoredPaths: string[] = []
38+
ignoredPaths: string[] = ['meta.args']
3939
): NonSerializableValue | false {
4040
let foundNestedSerializable: NonSerializableValue | false
4141

0 commit comments

Comments
 (0)