Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

doc: Update withDefault JSDocs #926

Merged
merged 1 commit into from
Feb 27, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions packages/nuqs/src/parsers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,17 @@ export type ParserBuilder<T> = Required<Parser<T>> &

/**
* Specifying a default value makes the hook state non-nullable when the
* query is missing from the URL.
* query is missing from the URL: the default value is returned instead
* of `null`.
*
* Note: if you wish to specify options as well, you need to call
* `withOptions` **before** `withDefault`.
* Setting the state to the default value¹ will clear the query string key
* from the URL, unless `clearOnDefault` is set to `false`.
*
* Setting the state to `null` will always clear the query string key
* from the URL, and return the default value.
*
* ¹: Equality is checked with the parser's `eq` function, or referential
* equality if not provided.
*
* @param defaultValue
*/
Expand Down
Loading