Client: Safeguard against missing localStorage
This commit is contained in:
12
client/src/utils/support.ts
Normal file
12
client/src/utils/support.ts
Normal file
@@ -0,0 +1,12 @@
|
||||
|
||||
function _isLocalStorageAvailable(): boolean {
|
||||
try {
|
||||
localStorage.setItem('test', 'test');
|
||||
localStorage.removeItem('test');
|
||||
return true;
|
||||
} catch (e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
export const isLocalStorageAvailable = _isLocalStorageAvailable();
|
||||
Reference in New Issue
Block a user