Skip to content

Commit a061836

Browse files
committed
fix: Handle empty strings
1 parent 057c376 commit a061836

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/useQueryState.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import React from 'react'
21
import { useRouter } from 'next/router'
2+
import React from 'react'
33
import { HistoryOptions, Serializers } from './defs'
44

55
export interface UseQueryStateOptions<T> extends Serializers<T> {
@@ -116,7 +116,7 @@ export function useQueryState<T = string>(
116116
}
117117
const query = new URLSearchParams(window.location.search)
118118
const value = query.get(key)
119-
return value ? parse(value) : null
119+
return value !== null ? parse(value) : null
120120
}, [])
121121

122122
// Update the state value only when the relevant key changes.

0 commit comments

Comments
 (0)