lxieyang / chrome-extension-boilerplate-react

A Chrome Extensions boilerplate using React 18 and Webpack 5.
MIT License
3.57k stars 1.1k forks source link

Cant save data to localstorage #104

Closed hungdev closed 2 years ago

hungdev commented 2 years ago

thank for your template, @lxieyang In Popup.jsx i used:

      chrome.storage.local.set({ 'value': 'theValue' }, function () {
        // Notify that we saved.
        console.log('Settings saved'); 
      });

I can see the log 'Settings saved' show up, but when i inspect and open Application tab, i dont see value that i inserted here? what's wrong with me?

image Thank you

hungdev commented 2 years ago

i misunderstand about chrome.storage and localStorage

cancan101 commented 2 years ago

What was the conclusion / fix here?

hungdev commented 2 years ago

@cancan101 chrome.storage will save data in extension storage, and localStorage will save in chrome => application tab so im using chrome.storage.local.set, it cant save in application tab. If you want to save to application tab of chrome, you need to use localStorage.setItem