mirror of
https://github.com/shishantbiswas/bknd.git
synced 2026-03-17 12:56:05 +00:00
added format command and added trailing commas to reduce conflicts
This commit is contained in:
@@ -5,7 +5,7 @@ import {
|
||||
Type,
|
||||
decodeSearch,
|
||||
encodeSearch,
|
||||
parseDecode
|
||||
parseDecode,
|
||||
} from "core/utils";
|
||||
import { isEqual, transform } from "lodash-es";
|
||||
import { useLocation, useSearch as useWouterSearch } from "wouter";
|
||||
@@ -13,7 +13,7 @@ import { useLocation, useSearch as useWouterSearch } from "wouter";
|
||||
// @todo: migrate to Typebox
|
||||
export function useSearch<Schema extends TSchema = TSchema>(
|
||||
schema: Schema,
|
||||
defaultValue?: Partial<StaticDecode<Schema>>
|
||||
defaultValue?: Partial<StaticDecode<Schema>>,
|
||||
) {
|
||||
const searchString = useWouterSearch();
|
||||
const [location, navigate] = useLocation();
|
||||
@@ -34,7 +34,7 @@ export function useSearch<Schema extends TSchema = TSchema>(
|
||||
if (defaultValue && isEqual(value, defaultValue[key])) return;
|
||||
result[key] = value;
|
||||
},
|
||||
{} as Static<Schema>
|
||||
{} as Static<Schema>,
|
||||
);
|
||||
const encoded = encodeSearch(search, { encode: false });
|
||||
navigate(location + (encoded.length > 0 ? "?" + encoded : ""));
|
||||
@@ -42,6 +42,6 @@ export function useSearch<Schema extends TSchema = TSchema>(
|
||||
|
||||
return {
|
||||
value: value as Required<StaticDecode<Schema>>,
|
||||
set
|
||||
set,
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user