We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 6ef94b2 commit 0c097e4Copy full SHA for 0c097e4
components/Editor.js
@@ -5,7 +5,10 @@ import { CodeSandbox } from "./CodeSandbox";
5
const Editors = { Glitch, CodeSandbox };
6
7
export const useLocalStorage = (key, defaultValue) => {
8
- const [state, setState] = useState(() => localStorage[key] ?? defaultValue);
+ const [state, setState] = useState(
9
+ () =>
10
+ typeof localStorage !== "undefined" || (localStorage[key] ?? defaultValue)
11
+ );
12
useEffect(() => {
13
if (state != null && key != null) {
14
localStorage[key] = state;
0 commit comments