jhen0409 / react-chrome-extension-boilerplate

Boilerplate for Chrome Extension React.js project
MIT License
2.14k stars 388 forks source link

Same store, different root #68

Open altany opened 7 years ago

altany commented 7 years ago

I added an extra view for the new tab and it works great! Also, I updated the popup view to render a form for adding a new item to the list. All works great but I still need to refresh the new tab window to see the new item.

What I would like to do is have the new item show automatically in the new tab list when I add it via the popup. Does anyone know if I can make it work without refresh?

For reference, I replaced #root with #popupRoot in popup.pug, and then edited todoapp.js as:

...

const createStore = require('../../app/store/configureStore');
const store = createStore(initialState);

if (document.querySelector('#root')) {
    ReactDOM.render(
      <Root store={store} />,
      document.querySelector('#root')
    );
  }
  if (document.querySelector('#popupRoot')) {
    ReactDOM.render(
      <PopupRoot store={store}/>,
      document.querySelector('#popupRoot')
    );
  }