Skip to content

Commit

Permalink
handle undefined values
Browse files Browse the repository at this point in the history
  • Loading branch information
riccardobl committed Dec 23, 2024
1 parent 8694626 commit 5525a6d
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions components/use-local-state.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { useCallback, useState } from 'react'

export function setValue (storageKey, value) {
if (SSR) return
if (value === undefined) value = null
window.localStorage.setItem(storageKey, JSON.stringify(value))
}

Expand Down

0 comments on commit 5525a6d

Please sign in to comment.