Skip to content

Commit

Permalink
climbing: Fix undefined window
Browse files Browse the repository at this point in the history
  • Loading branch information
jvaclavik committed Apr 7, 2024
1 parent 12887c8 commit b4f6e74
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/components/FeaturePanel/Climbing/utils/ascents.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ const KEY = 'ascents';

// @TODO generic util?
export const getLocalStorageItem = (key: string) => {
if (typeof window === 'undefined') return [];
const raw = window?.localStorage.getItem(key);
if (raw) {
try {
Expand All @@ -19,6 +20,7 @@ export const getLocalStorageItem = (key: string) => {

// @TODO generic util?
export const setLocalStorageItem = (key: string, value: JSONValue) => {
if (typeof window === 'undefined') return;
window?.localStorage.setItem(key, JSON.stringify(value));
};

Expand Down

0 comments on commit b4f6e74

Please sign in to comment.