Hi am getting a problem when i try to get the cache from the localStorage
This is my function like the swr docs
function localStorageProvider() {
// When initializing, we restore the data from `localStorage` into a map.
const map = new Map(JSON.parse(localStorage.getItem('app-cache') || '[]'))
// Before unloading the app, we write back all the data into `localStorage`.
window.addEventListener('beforeunload', () => {
const appCache = JSON.stringify(Array.from(map.entries()))
localStorage.setItem('app-cache', appCache)
})
// We still use the map for write & read for performance.
return map
}
When i refresh the page i am getting the error of cannot read properties of undefined [0] .......
I already worked with swr cache before and didn't have any problems, maybe a version issue or something?
Thanks in advance