tshaddix / webext-redux

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

What is way to creating Chrome extention with default create-react-app? #268

Closed vakhno closed 3 years ago

vakhno commented 3 years ago

Well, i have created an chrome extention with create-react-app and its worked ok, but when i started to connecting default redux I noticed that redux actions correctly worked (I could see changes from Redux DevTools Inspector pangel) only locally (on 3000 port) and when I opened it from Chrome extension list and opened Redux DevTools i have seen that my store not exist (No store found), but I still could manipulating with store but he updating it after restart extention. Then I have decided to connect webext-redux package to overcome this problem. Doing everything according to the documentation. 1)Created an bacgkround.js file image

2)Setup manifest.json with "background" and "browser_action" image

3)Background.js

 import {wrapStore} from 'webext-redux';
 const store; 
 wrapStore(store);

4)Index.js

 import {ReactDOM} from 'react-dom'
 import App from './App'
 import {Provider} from 'react-redux'
 import {Store} from 'webext-redux'

 const store = new Store();

 store.ready().then(() => {
   ReactDOM.render(
     <Provider store={store}>
       <App/>
     </Provider>,
     document.getElementById('root')
   )
 })

And after this manipulations I have opened my extention and saw in console error "Unchecked runtime.lastError: Could not establish connection. Receiving end does not exist.". I spent the whole day to overcome this mistake, but I still couldn't solve it. And when I was looking for a solution to the problem, I came to the conclusion (thanks to #222) that the problem is the interaction between 'create-react-app' and 'webext-redux'. Is it possible to get webext-redux to work together with create-react-app?