@mirohq/design-system-use-local-storage
Advanced tools
Comparing version 0.3.1 to 0.3.2
@@ -11,2 +11,5 @@ 'use strict'; | ||
function getLocalStorageValue(key, defaultValue) { | ||
if (typeof window === "undefined") { | ||
return defaultValue; | ||
} | ||
try { | ||
@@ -17,3 +20,3 @@ const stored = window.localStorage.getItem(key); | ||
console.error( | ||
"[useLocalStorage] Error reading localStorage key \u201C".concat(key, "\u201D:"), | ||
`[useLocalStorage] Error reading localStorage key \u201C${key}\u201D:`, | ||
e | ||
@@ -25,2 +28,5 @@ ); | ||
function setLocalStorageValue(key, value) { | ||
if (typeof window === "undefined") { | ||
return; | ||
} | ||
try { | ||
@@ -30,3 +36,3 @@ window.localStorage.setItem(key, JSON.stringify(value)); | ||
console.error( | ||
"[useLocalStorage] Error setting localStorage key \u201C".concat(key, "\u201D:"), | ||
`[useLocalStorage] Error setting localStorage key \u201C${key}\u201D:`, | ||
e | ||
@@ -37,2 +43,5 @@ ); | ||
function removeLocalStorageValue(key) { | ||
if (typeof window === "undefined") { | ||
return; | ||
} | ||
try { | ||
@@ -42,3 +51,3 @@ window.localStorage.removeItem(key); | ||
console.error( | ||
"[useLocalStorage] Error removing localStorage key \u201C".concat(key, "\u201D:"), | ||
`[useLocalStorage] Error removing localStorage key \u201C${key}\u201D:`, | ||
e | ||
@@ -50,3 +59,3 @@ ); | ||
const prefixedKey = react.useMemo( | ||
() => "".concat(prefix != null ? prefix : KEY_PREFIX, "_").concat(key), | ||
() => `${prefix != null ? prefix : KEY_PREFIX}_${key}`, | ||
[prefix, key] | ||
@@ -53,0 +62,0 @@ ); |
@@ -7,2 +7,5 @@ import { useEventListener } from '@mirohq/design-system-use-event-listener'; | ||
function getLocalStorageValue(key, defaultValue) { | ||
if (typeof window === "undefined") { | ||
return defaultValue; | ||
} | ||
try { | ||
@@ -13,3 +16,3 @@ const stored = window.localStorage.getItem(key); | ||
console.error( | ||
"[useLocalStorage] Error reading localStorage key \u201C".concat(key, "\u201D:"), | ||
`[useLocalStorage] Error reading localStorage key \u201C${key}\u201D:`, | ||
e | ||
@@ -21,2 +24,5 @@ ); | ||
function setLocalStorageValue(key, value) { | ||
if (typeof window === "undefined") { | ||
return; | ||
} | ||
try { | ||
@@ -26,3 +32,3 @@ window.localStorage.setItem(key, JSON.stringify(value)); | ||
console.error( | ||
"[useLocalStorage] Error setting localStorage key \u201C".concat(key, "\u201D:"), | ||
`[useLocalStorage] Error setting localStorage key \u201C${key}\u201D:`, | ||
e | ||
@@ -33,2 +39,5 @@ ); | ||
function removeLocalStorageValue(key) { | ||
if (typeof window === "undefined") { | ||
return; | ||
} | ||
try { | ||
@@ -38,3 +47,3 @@ window.localStorage.removeItem(key); | ||
console.error( | ||
"[useLocalStorage] Error removing localStorage key \u201C".concat(key, "\u201D:"), | ||
`[useLocalStorage] Error removing localStorage key \u201C${key}\u201D:`, | ||
e | ||
@@ -46,3 +55,3 @@ ); | ||
const prefixedKey = useMemo( | ||
() => "".concat(prefix != null ? prefix : KEY_PREFIX, "_").concat(key), | ||
() => `${prefix != null ? prefix : KEY_PREFIX}_${key}`, | ||
[prefix, key] | ||
@@ -49,0 +58,0 @@ ); |
{ | ||
"name": "@mirohq/design-system-use-local-storage", | ||
"version": "0.3.1", | ||
"version": "0.3.2", | ||
"description": "", | ||
@@ -29,4 +29,4 @@ "author": "Miro", | ||
"@mirohq/design-system-types": "^0.6.0", | ||
"@mirohq/design-system-use-event-listener": "^0.3.0", | ||
"@mirohq/design-system-use-event": "^0.2.0" | ||
"@mirohq/design-system-use-event": "^0.2.0", | ||
"@mirohq/design-system-use-event-listener": "^0.3.0" | ||
}, | ||
@@ -33,0 +33,0 @@ "scripts": { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
17402
167