Skip to content

Commit

Permalink
Ignore serializability of meta.args by default
Browse files Browse the repository at this point in the history
  • Loading branch information
markerikson committed Mar 5, 2020
1 parent 1279c3f commit 75c7b89
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
23 changes: 23 additions & 0 deletions src/serializableStateInvariantMiddleware.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -385,4 +385,27 @@ describe('serializableStateInvariantMiddleware', () => {
(See https://redux.js.org/faq/organizing-state#can-i-put-functions-promises-or-other-non-serializable-items-in-my-store-state)"
`)
})

it('should not check serializability for meta.args by default', () => {
const badValue = new Map()

const reducer: Reducer = (state = 42, action) => {
return state
}

const serializableStateInvariantMiddleware = createSerializableStateInvariantMiddleware()

const store = configureStore({
reducer: {
testSlice: reducer
},
middleware: [serializableStateInvariantMiddleware]
})

store.dispatch({ type: 'testAction', meta: { args: { badValue } } })

const { log } = getLog()
expect(log).toBe('')
const q = 42
})
})
2 changes: 1 addition & 1 deletion src/serializableStateInvariantMiddleware.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export function findNonSerializableValue(
path: ReadonlyArray<string> = [],
isSerializable: (value: unknown) => boolean = isPlain,
getEntries?: (value: unknown) => [string, any][],
ignoredPaths: string[] = []
ignoredPaths: string[] = ['meta.args']
): NonSerializableValue | false {
let foundNestedSerializable: NonSerializableValue | false

Expand Down

0 comments on commit 75c7b89

Please sign in to comment.