tshaddix / webext-redux

A set of utilities for building Redux applications in Web Extensions.
MIT License
1.22k stars 179 forks source link

Alias example not working. Actions must be plain objects. Use custom middleware for async actions. #255

Closed GhazanfarKhan closed 4 years ago

GhazanfarKhan commented 4 years ago

Hi,

I am dispatching alias from content script given in example docs. I got following error.

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

I have used thunk also in proxy store and from there I dispatched it. I checked code in background script, this function throwing error after webpack build. Action is coming undefined.

function dispatch(action) {
    if (!isPlainObject(action)) {
      throw new Error('Actions must be plain objects. ' + 'Use custom middleware for async actions.');
    }

    if (typeof action.type === 'undefined') {
      throw new Error('Actions may not have an undefined "type" property. ' + 'Have you misspelled a constant?');
    }

    if (isDispatching) {
      throw new Error('Reducers may not dispatch actions.');
    }

    try {
      isDispatching = true;
      currentState = currentReducer(currentState, action);
    } finally {
      isDispatching = false;
    }

    var listeners = currentListeners = nextListeners;

    for (var i = 0; i < listeners.length; i++) {
      var listener = listeners[i];
      listener();
    }

    return action;
  }
GhazanfarKhan commented 4 years ago

I was not return from alias. I provide a return statement with some dispatch.

jasan-s commented 3 years ago

Getting the same error as well