catch possible permission error from localstorage (#103)

This commit is contained in:
dank074 2022-12-22 21:22:16 -06:00 committed by GitHub
parent c7b4761a4a
commit bb37d84d99
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1 +1,11 @@
export const GetLocalStorage = <T>(key: string) => JSON.parse(window.localStorage.getItem(key)) as T ?? null;
export const GetLocalStorage = <T>(key: string) =>
{
try
{
JSON.parse(window.localStorage.getItem(key)) as T ?? null
}
catch(e)
{
return null;
}
}