Skip to content

Commit

Permalink
Add an attempt to set/get item from localstorage (#205)
Browse files Browse the repository at this point in the history
  • Loading branch information
IanVS authored and rt2zz committed Nov 12, 2016
1 parent 6daad3f commit 89ee329
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/defaults/asyncLocalStorage.js
Expand Up @@ -9,9 +9,17 @@ const noStorage = process && process.env && process.env.NODE_ENV === 'production
}

function hasLocalStorage () {
let storageExists
try {
return typeof window === 'object' && !!window.localStorage
storageExists = (typeof window === 'object' && !!window.localStorage)
if (storageExists) {
const testKey = 'redux-persist localStorage test'
window.localStorage.setItem(testKey, true)
window.localStorage.getItem(testKey)
window.localStorage.removeItem(testKey)
}
} catch (e) { return false }
return storageExists
}

function hasSessionStorage () {
Expand Down

0 comments on commit 89ee329

Please sign in to comment.