jhen0409 / react-chrome-extension-boilerplate

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

syncronize across tabs with localstorage #22

Closed wiber closed 8 years ago

wiber commented 8 years ago

Hi,

Updating the popup doesn't persist to localstore or propagate to other windows where the extension is running. How would I rerender all reacts when localstore changes?

I'm looking to persist state to localstorage in a way similar to these:

https://github.com/STRML/react-localstorage http://stackoverflow.com/questions/21741754/react-js-syncing-entire-state-to-localstorage

I can then fire chrome.storage.onChanged.addListener but where does that go to reload the DOM(s) ?

Cheers,

Elias

wiber commented 8 years ago

If I understand redux (and do correct me if I'm wrong) persisting the actions to localstorage and applying them both from there and from the ui is the way to go? Or catching them up when window becomes active.

zalmoxisus commented 8 years ago

Yes, you are right, you have to persist redux states. Use redux-persist for that. To get it work with chrome.storage instead of window.localStorage, use chrome-storage-local. An example of configuration can be found here, which is used for returning the store asynchronously.

wiber commented 8 years ago

Thanks @zalmoxisus , that looks good.