12 lines
245 B
TypeScript
12 lines
245 B
TypeScript
export const safeLocalStorage = () => (isLocalStorage() ? localStorage : null)
|
|
|
|
const isLocalStorage = () => {
|
|
try {
|
|
localStorage.getItem('test')
|
|
localStorage.setItem('hi', 'mom')
|
|
return true
|
|
} catch (e) {
|
|
return false
|
|
}
|
|
}
|