question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Actions must be plain objects. Use custom middleware for async actions.

See original GitHub issue

ie issue

Previously it was working properly in ie11,However I am facing this issue from last week in IE11.It works on both firefox and chrome.

store.js `import rootReducer from ‘…/reducers’; import thunk from ‘redux-thunk’; import {applyMiddleware, compose, createStore} from ‘redux’; import createLogger from ‘redux-logger’; import routes from ‘…/routes’; import createHistory from ‘history/lib/createHashHistory’; import {reduxReactRouter} from ‘redux-router’; import config from ‘…/common/config’;

export default function configureStore(initialState) { let createStoreWithMiddleware;

const logger = createLogger();
let history = createHistory({
    queryKey: false
});

let middleware = applyMiddleware(thunk, logger);
if(config.Environment == 'PROD'){
    middleware = applyMiddleware(thunk);
}

createStoreWithMiddleware = compose(
    middleware,reduxReactRouter({ routes, history })
);

const store = createStoreWithMiddleware(createStore)(rootReducer, initialState);

if (module.hot) {
    module.hot
        .accept('../reducers', () => {
            const nextRootReducer = require('../reducers/index');
            store.replaceReducer(nextRootReducer);
        });
}

return store;

} `

package.json

...... "dependencies": { "babel": "^5.8.23", "babel-core": "^5.2.17", "babel-loader": "^5.0.0", "body-parser": "^1.12.4", "cookie-parser": "^1.3.3", "debug": "^2.2.0", "dotenv": "^1.2.0", "errorhandler": "^1.4.2", "es6-promise": "^3.0.2", ..... "highcharts": "5.0.0", "history": "^1.9.0", ..... "lodash": "^4.13.1", "material-ui": "0.18.2", "material-ui-pagination": "^1.0.1", .... "react": "15.4.1", "react-addons-css-transition-group": "^15.2.1", "react-addons-linked-state-mixin": "^15.2.1", ... "react-redux": "^4.4.5", "react-router": "^2.6.0", "react-tap-event-plugin": "2.0.1", "redux": "^3.5.2", "redux-logger": "^2.6.1", "redux-router": "^2.0.0", "redux-thunk": "^2.1.0", "rimraf": "^2.5.2" }, "devDependencies": { "babel-loader": "^5.0.0", "file-loader": "^0.8.4", "redux-devtools": "^3.0.1", "redux-devtools-dock-monitor": "^1.0.1", "redux-devtools-log-monitor": "^1.0.1", "webpack": "^1.11.0", "webpack-dev-server": "^1.10.1" }, ......

Need Help please.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:10

github_iconTop GitHub Comments

8reactions
dmndcommented, Nov 23, 2017

This thread helped a lot when debugging what was going on. Thanks @nachein & others!

For us, this actually had nothing to do with redux-thunk (we don’t use it). We saw this issue via redux itself: redux calls lodash’s isPlainObject function.

Without google maps, isPlainObject seemed to work as expected. But when we included the google maps API with v>=3.30, isPlainObject({}) would (crazily) return false!

While debugging I noticed that {}.toString returned "[Object Array Iterator]" which I think confused lodash.

I can only assume Google Maps is writing to Object.prototype somewhere, or otherwise messing with the browser environment.

5reactions
nacheincommented, Nov 23, 2017

you are totally right @dmnd, about not being related to redux-thunk but redux itself, and about isPlainObject issue.

After a bit of debugging I can see that the error occurs on reduxs’ init action, and if I test isPlainObject({}) I also get false.

EDIT:

Another info I can provide is that on my case, it’s only happening on production builds (minified) and not on dev builds.

EDIT2:

Also can confirm that ({}).toString() is returning [object Array Iterator] with gmaps v3 and [object Object] on gmaps v3.29.

This is makingisPlainObject return false and true respectively.

EDIT3:

I don’t think Google Maps is writing Object prototype. What I can see is a difference on Symbol.toStringTag, which from what I read, is used internally on Object.toString:

Symbol.toStringTag | This property returns a string value that is used to help create the default string description of an object. It is used internally by the built-in method Object.toStringmethod.

Since IE11 does not support Symbol, there may be a conflict between gmaps and the polyfill.

When running Symbol.toStringTag;

  • With gmaps v3.29 returns an object, that seems to be the correct polyfill
  • With gmaps v3 returns a string -> jscomp_symbol_Symbol.toStringTag1

This is what makes lodash isPlainObject return false (baseGetTag(value) != objectTag).

Read more comments on GitHub >

github_iconTop Results From Across the Web

React-Redux: Actions must be plain objects. Use custom ...
This error occurs mainly if you are dispatching an action and your action is not returning an object. For example here ...
Read more >
Actions must be plain objects. Use custom ... - GitHub
I am trying to resolve this issue. Am new to react. Here is my offer action import axios from 'axios'; // offers export...
Read more >
error: actions must be plain objects. instead, the actual type ...
"Error: Actions must be plain objects. Instead, the actual type was: 'Promise'. You may need to add middleware to your store setup to...
Read more >
Error: Actions must be plain objects. Use custom ... - YouTube
Error: Actions must be plain objects. Use custom middleware for async actions. 4K views 1 year ago. paradise _hope. paradise _hope.
Read more >
Async actions in bare Redux with Thunk or custom middleware
Learn how to manage asynchronous actions in React apps with Redux Toolkit, or a bare Redux implementation with custom middleware.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found