Skip to content

Commit

Permalink
docs: jsdoc
Browse files Browse the repository at this point in the history
  • Loading branch information
wanjas committed Jan 26, 2024
1 parent a5662ca commit c6da380
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
9 changes: 8 additions & 1 deletion packages/core/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,13 @@ import {

export type { DefaultSchema, UrlState } from './types';

/**
* Creates a hook that will manage the state of the URL search params.
* @param {z.ZodObject} schema - zod schema to verify the url state
* @param {Object} [initialValue] - initial value of the state
* @param {UrlStateOptions} [options]
* @param {boolean} [options.applyInitialValue] - if true, the initial value will be applied to the URL
*/
export function useUrlState<T extends DefaultSchema>(
schema: T,
initialValue?: UrlStateValue<T> | null,
Expand Down Expand Up @@ -45,7 +52,7 @@ export function useUrlStateWithRouter<T extends DefaultSchema>(
isReady: false,
});

// needed it order to make handler functions stable
// need this in order to make handler functions stable
const stateRef = useRef(state);
stateRef.current = state;

Expand Down
3 changes: 3 additions & 0 deletions packages/core/src/types.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
import { z } from 'zod';

export type UrlStateOptions = {
/**
* If true, the initial value will be applied to the URL.
*/
applyInitialValue: boolean;
};

Expand Down

0 comments on commit c6da380

Please sign in to comment.