Skip to content

Commit c6da380

Browse files
committed
docs: jsdoc
1 parent a5662ca commit c6da380

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

packages/core/src/index.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,13 @@ import {
1616

1717
export 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+
*/
1926
export 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

packages/core/src/types.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
import { z } from 'zod';
22

33
export type UrlStateOptions = {
4+
/**
5+
* If true, the initial value will be applied to the URL.
6+
*/
47
applyInitialValue: boolean;
58
};
69

0 commit comments

Comments
 (0)