Missing utils.
This commit is contained in:
parent
f961e390a1
commit
4e908fdafb
1 changed files with 16 additions and 0 deletions
16
src/utils/utils.js
Normal file
16
src/utils/utils.js
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
export const hasLocalStorage = () => {
|
||||
try {
|
||||
var ls = localStorage;
|
||||
var key = "__test";
|
||||
ls.setItem(key, key);
|
||||
ls.removeItem(key);
|
||||
return true;
|
||||
} catch (e) {
|
||||
return (
|
||||
e instanceof DOMException &&
|
||||
e.name === "QuotaExceededError" &&
|
||||
localStorage &&
|
||||
localStorage.length !== 0
|
||||
);
|
||||
}
|
||||
}
|
||||
Loading…
Reference in a new issue