ken
ken

Reputation: 9013

Redux Dev Tools reporting <UNDEFINED> type

I am relatively new to Redux but I'm finding that in a few cases the devtools report an Action type of <UNDEFINED> and yet by printing to console immediately before dispatch (in the action creator) I see that the object does indeed have it's type:

enter image description here

console output

Has anyone else seen this behaviour?

Upvotes: 0

Views: 1377

Answers (2)

Minh To&#224;n
Minh To&#224;n

Reputation: 21

I think you've imported the action as an function, try to call (payload) might solve your issue

Upvotes: 0

Zalmoxisus
Zalmoxisus

Reputation: 161

It just means that the action type is not serialized via JSON.stringify. Most likely you're using ES6 Symbol as type. So, JSON.stringify({ type: Symbol('BECOMES_UNDEFINED') }) === '{}'.

If you want Redux DevTools Extension to support unserializable data, set serialize parameter to true:

const store = Redux.createStore(reducer, window.__REDUX_DEVTOOLS_EXTENSION__ && window.__REDUX_DEVTOOLS_EXTENSION__({
   serialize: true
}));

It will handle dates, regexes, undefined, error objects, symbols and functions.

Upvotes: 2

Related Questions