Skip to content

Commit e5e9e81

Browse files
authored
doc: Update withDefault JSDocs (#926)
1 parent 0c955ce commit e5e9e81

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

packages/nuqs/src/parsers.ts

+10-3
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,17 @@ export type ParserBuilder<T> = Required<Parser<T>> &
4242

4343
/**
4444
* Specifying a default value makes the hook state non-nullable when the
45-
* query is missing from the URL.
45+
* query is missing from the URL: the default value is returned instead
46+
* of `null`.
4647
*
47-
* Note: if you wish to specify options as well, you need to call
48-
* `withOptions` **before** `withDefault`.
48+
* Setting the state to the default value¹ will clear the query string key
49+
* from the URL, unless `clearOnDefault` is set to `false`.
50+
*
51+
* Setting the state to `null` will always clear the query string key
52+
* from the URL, and return the default value.
53+
*
54+
* ¹: Equality is checked with the parser's `eq` function, or referential
55+
* equality if not provided.
4956
*
5057
* @param defaultValue
5158
*/

0 commit comments

Comments
 (0)