Skip to content

Commit fb5dc5a

Browse files
committed
fix
1 parent c431437 commit fb5dc5a

2 files changed

Lines changed: 8 additions & 4 deletions

File tree

src/hooks/useLocalStorage/useLocalStorage.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ export function useLocalStorage<T>(
9595
const current: T =
9696
currentRaw === undefined
9797
? initialValue
98-
: parseJSON<T>(currentRaw, initialValue);
98+
: parseJSON(currentRaw, initialValue);
9999
const next = isFunction(updater) ? updater(current) : updater;
100100
const serialized = JSON.stringify(next);
101101
try {

src/hooks/useMediaQuery/useMediaQuery.stories.tsx

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import type { Meta, StoryObj } from "@storybook/nextjs-vite";
22
import { useId, useState } from "react";
33
import { useMediaQuery } from "./useMediaQuery";
44
import { Input } from "../../components/Input";
5+
import { isValueOf } from "../../utils/isValueOf";
56

67
const QUERIES = [
78
"(min-width: 768px)",
@@ -17,8 +18,8 @@ const meta = {
1718
layout: "centered",
1819
},
1920
render: () => {
20-
const [query, setQuery] = useState<string>(QUERIES[0]);
21-
const [lastEvent, setLastEvent] = useState<string>("none");
21+
const [query, setQuery] = useState<(typeof QUERIES)[number]>(QUERIES[0]);
22+
const [lastEvent, setLastEvent] = useState("none");
2223
const queryId = useId();
2324
const resultId = useId();
2425
const eventId = useId();
@@ -35,7 +36,10 @@ const meta = {
3536
className="rounded border p-1"
3637
id={queryId}
3738
onChange={(e) => {
38-
setQuery(e.target.value);
39+
const { value } = e.target;
40+
if (isValueOf(QUERIES, value)) {
41+
setQuery(value);
42+
}
3943
}}
4044
value={query}
4145
>

0 commit comments

Comments
 (0)