Skip to content

Commit

Permalink
Remove localStorage warning.
Browse files Browse the repository at this point in the history
  • Loading branch information
RubenVerborgh committed Aug 18, 2019
1 parent 008518e commit 5d18397
Showing 1 changed file with 3 additions and 14 deletions.
17 changes: 3 additions & 14 deletions src/storage.js
Expand Up @@ -12,20 +12,9 @@ export interface AsyncStorage {
export type Storage = Storage | AsyncStorage

export const defaultStorage = () => {
try {
if (window && window.localStorage) {
return asyncStorage(window.localStorage)
}
} catch (e) {
if (!(e instanceof ReferenceError)) {
throw e
}
}
console.warn(
`'window.localStorage' unavailable. ` +
`Creating a (not very useful) in-memory storage object as the default storage interface.`
)
return asyncStorage(memStorage())
const hasLocalStorage =
typeof window !== 'undefined' && 'localStorage' in window
return asyncStorage(hasLocalStorage ? window.localStorage : memStorage())
}

/**
Expand Down

0 comments on commit 5d18397

Please sign in to comment.