Skip to content

Commit

Permalink
Fix typo on store.tsx (#875)
Browse files Browse the repository at this point in the history
  • Loading branch information
giubrocchi committed Jan 10, 2024
1 parent 8e8a503 commit 32cdfef
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion packages/preview-astro/src/store/store.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
import { atom } from "nanostores";

export const serachWord = atom<string>("");
export const searchWord = atom<string>("");
8 changes: 4 additions & 4 deletions packages/preview-astro/src/utils/usesearch.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from "react";
import { useHashParams } from "./usehashparams";
import { serachWord } from "../store/store";
import { searchWord } from "../store/store";
import { useStore } from "@nanostores/react";
import { navigate } from "astro:transitions/client";

Expand All @@ -11,12 +11,12 @@ interface UseSearchValue {

export function useSearch(): UseSearchValue {
const [params] = useHashParams();
const query = useStore(serachWord);
const query = useStore(searchWord);

const q = params.get("q");
React.useEffect(() => {
const newQuery = typeof q === "string" ? q.toLowerCase() : "";
serachWord.set(newQuery);
searchWord.set(newQuery);
}, [q]);

const setQuery = React.useCallback((query: string) => {
Expand All @@ -25,7 +25,7 @@ export function useSearch(): UseSearchValue {
? "replace"
: "push";
navigate(`/react-icons/search/#q=${query}`, { history });
serachWord.set(query);
searchWord.set(query);
}, []);

return {
Expand Down

0 comments on commit 32cdfef

Please sign in to comment.