tshaddix/webext-redux

error when creating store

lippyDesign opened this issue · 5 comments

In the following code I am getting an error when doing const store = new Store();

The error says:

Uncaught ReferenceError: browser is not defined at getBrowserAPI (util.js:19) at new Store (Store.js:83) at eval (popup.js:14) at Module../src/scripts/popup.js (popup.js:790) at __webpack_require__ (popup.js:20) at popup.js:84 at popup.js:87

`import React from 'react';
import {render} from 'react-dom';
import {Provider} from 'react-redux';
import {Store} from 'webext-redux';

const App = () =>

APP

const store = new Store();

// wait for the store to connect to the background page
store.ready().then(() => {
// The store implements the same interface as Redux's store
// so you can use tools like react-redux no problem!
render(



, document.getElementById('app'));
});
`

Figured it out, in case if someone runs into this. It started working after I removed the node flag from webpack.js

@lippyDesign Glad you figured this out!

@lippyDesign curious to know which flag you removed from (what I gather was) your webpack config file? I'm encountering the same error with a content script which injects an iframe (where the iframe accesses the store).

Strangely this only affects Firefox - everything works swimmingly in chrome.

i believe it was a node version flag or something that had to do with node js

i believe it was a node version flag or something that had to do with node js

Thanks @lippyDesign . I don't have any node specifc config that I can see ... I'lll need to keep digging.