fenextjs-hook
Advanced tools
Comparing version 1.2.28 to 1.2.29
@@ -23,6 +23,9 @@ /** | ||
export type useQuery_QueryKeysProps = keyof useQuery_QueryProps; | ||
export interface useQueryProps { | ||
ignoreQuerys: [id: useQuery_QueryKeysProps]; | ||
} | ||
/** | ||
* A hook that provides access to the query parameters in the URL. | ||
*/ | ||
export declare const useQuery: () => { | ||
export declare const useQuery: (props?: Partial<useQueryProps>) => { | ||
query: useQuery_QueryProps; | ||
@@ -29,0 +32,0 @@ setQuery: (query: useQuery_QueryProps) => void; |
@@ -9,3 +9,4 @@ "use strict"; | ||
*/ | ||
const useQuery = () => { | ||
const useQuery = (props) => { | ||
const { ignoreQuerys } = (0, react_1.useMemo)(() => props ?? {}, [props]); | ||
/** | ||
@@ -25,3 +26,3 @@ * Whether the query has been changed. | ||
const { id = undefined, search = "", searchAddress = "", tab = "all", page = "0", npage = "10", totalpage = "100", allitems = "1000", start = undefined, end = undefined, order = undefined, orderBy = undefined, ...props } = q; | ||
return { | ||
const r = { | ||
id, | ||
@@ -42,3 +43,7 @@ search, | ||
}; | ||
}, [router.query]); | ||
(ignoreQuerys ?? []).map((e) => { | ||
delete r[e]; | ||
}); | ||
return r; | ||
}, [router.query, ignoreQuerys]); | ||
/** | ||
@@ -45,0 +50,0 @@ * Sets the query parameters in the URL. |
@@ -23,6 +23,9 @@ /** | ||
export type useQuery_QueryKeysProps = keyof useQuery_QueryProps; | ||
export interface useQueryProps { | ||
ignoreQuerys: [id: useQuery_QueryKeysProps]; | ||
} | ||
/** | ||
* A hook that provides access to the query parameters in the URL. | ||
*/ | ||
export declare const useQuery: () => { | ||
export declare const useQuery: (props?: Partial<useQueryProps>) => { | ||
query: useQuery_QueryProps; | ||
@@ -29,0 +32,0 @@ setQuery: (query: useQuery_QueryProps) => void; |
@@ -6,3 +6,4 @@ import { useRouter } from "next/router"; | ||
*/ | ||
export const useQuery = () => { | ||
export const useQuery = (props) => { | ||
const { ignoreQuerys } = useMemo(() => props ?? {}, [props]); | ||
/** | ||
@@ -22,3 +23,3 @@ * Whether the query has been changed. | ||
const { id = undefined, search = "", searchAddress = "", tab = "all", page = "0", npage = "10", totalpage = "100", allitems = "1000", start = undefined, end = undefined, order = undefined, orderBy = undefined, ...props } = q; | ||
return { | ||
const r = { | ||
id, | ||
@@ -39,3 +40,7 @@ search, | ||
}; | ||
}, [router.query]); | ||
(ignoreQuerys ?? []).map((e) => { | ||
delete r[e]; | ||
}); | ||
return r; | ||
}, [router.query, ignoreQuerys]); | ||
/** | ||
@@ -42,0 +47,0 @@ * Sets the query parameters in the URL. |
{ | ||
"name": "fenextjs-hook", | ||
"version": "1.2.28", | ||
"version": "1.2.29", | ||
"description": "", | ||
@@ -5,0 +5,0 @@ "main": "./dist/cjs/index.js", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
98401
1856