I am developing a React Chrome extension using the React-Chrome-Redux library
This is the first time I am developing this, and I am stuck in a mistake that I cannot understand the reason.
The following error message appears in a pop-up application at runtime:
Error in event handler for (unknown): TypeError: Unable to read the 'error' property from undefined
I tried to debug and set a breakpoint at the exact location of the error:
return new Promise(function (resolve, reject) { chrome.runtime.sendMessage({ type: _constants.DISPATCH_TYPE, payload: data }, function (_ref2) { var error = _ref2.error; var value = _ref2.value; if (error) { reject((0, _assignIn2.default)(new Error(), error)); } else { resolve(value.payload); } }); }); }
in the callback, Promise _ref2 is undefined when the action is: type: "chromex.dispatch", and the payload is also undefined.
It started after the introduction of the sending method to start the authentication process, the code is as follows:
class App extends Component { constructor(props) { super(props); this.props.dispatch({ type: START_AUTH }); }
On both popup / index.js and background / index.js, I set the storeβs communication channel:
//popup import {Store} from 'react-chrome-redux'; import {Provider} from 'react-redux'; const proxyStore = new Store({ portName: 'my_app' }); //background import rootReducer from '../core/reducers'; import {wrapStore} from 'react-chrome-redux'; import {render} from 'react-dom'; import {Provider} from 'react-redux'; import {Store} from 'react-chrome-redux'; import App from './components/App'; const store = createStore(rootReducer, {}); wrapStore(store, { portName: 'my_app' });
I have a lot of registration messages during the authentication process, but nothing happens.
In the kernel / I have common files, such as reducers, types of actions, actions, etc., it is always translated from ES6 using webpack-babel.
Unfortunately, it seems that React dev tools do not work with Chrome extensions to help debug.
Any idea or any additional information you need to help me figure out what's going on and how to fix it?