From 5525a6d650c4f2df454518c74e32b6c3663a087f Mon Sep 17 00:00:00 2001 From: Riccardo Balbo Date: Mon, 23 Dec 2024 19:40:54 +0100 Subject: [PATCH] handle undefined values --- components/use-local-state.js | 1 + 1 file changed, 1 insertion(+) diff --git a/components/use-local-state.js b/components/use-local-state.js index 95441cc78..e84362afe 100644 --- a/components/use-local-state.js +++ b/components/use-local-state.js @@ -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)) }