Skip to content

Commit

Permalink
only test getItem, show useful warning outside of prod
Browse files Browse the repository at this point in the history
  • Loading branch information
rt2zz committed Nov 12, 2016
1 parent 89ee329 commit 19c96cd
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/defaults/asyncLocalStorage.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,13 @@ function hasLocalStorage () {
storageExists = (typeof window === 'object' && !!window.localStorage)
if (storageExists) {
const testKey = 'redux-persist localStorage test'
window.localStorage.setItem(testKey, true)
// @TODO should we also test set and remove?
window.localStorage.getItem(testKey)
window.localStorage.removeItem(testKey)
}
} catch (e) { return false }
} catch (e) {
if (process && process.env && process.env.NODE_ENV === 'production') console.warn('redux-persist localStorage getItem test failed, persistence will be disabled.')

This comment has been minimized.

Copy link
@IanVS

IanVS Nov 15, 2016

Contributor

Should this be a !== 'production' ?

This comment has been minimized.

Copy link
@rt2zz

rt2zz Nov 17, 2016

Author Owner

yikes good catch, updating now

return false
}
return storageExists
}

Expand Down

0 comments on commit 19c96cd

Please sign in to comment.