File tree Expand file tree Collapse file tree 2 files changed +11
-1
lines changed Expand file tree Collapse file tree 2 files changed +11
-1
lines changed Original file line number Diff line number Diff line change @@ -16,6 +16,13 @@ import {
1616
1717export type { DefaultSchema , UrlState } from './types' ;
1818
19+ /**
20+ * Creates a hook that will manage the state of the URL search params.
21+ * @param {z.ZodObject } schema - zod schema to verify the url state
22+ * @param {Object } [initialValue] - initial value of the state
23+ * @param {UrlStateOptions } [options]
24+ * @param {boolean } [options.applyInitialValue] - if true, the initial value will be applied to the URL
25+ */
1926export function useUrlState < T extends DefaultSchema > (
2027 schema : T ,
2128 initialValue ?: UrlStateValue < T > | null ,
@@ -45,7 +52,7 @@ export function useUrlStateWithRouter<T extends DefaultSchema>(
4552 isReady : false ,
4653 } ) ;
4754
48- // needed it order to make handler functions stable
55+ // need this in order to make handler functions stable
4956 const stateRef = useRef ( state ) ;
5057 stateRef . current = state ;
5158
Original file line number Diff line number Diff line change 11import { z } from 'zod' ;
22
33export type UrlStateOptions = {
4+ /**
5+ * If true, the initial value will be applied to the URL.
6+ */
47 applyInitialValue : boolean ;
58} ;
69
You can’t perform that action at this time.
0 commit comments