Skip to content

Commit 91b4993

Browse files
committed
fix: be more defensive about reading updateType
1 parent caec137 commit 91b4993

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

packages/use-query-params/src/updateSearchString.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,9 @@ export function updateSearchString({
121121
};
122122

123123
if (navigate) {
124-
if (updateType?.startsWith('replace')) {
124+
// be defensive about checking updateType since it is somewhat easy to
125+
// accidentally pass a second argument to the setter.
126+
if (typeof updateType === 'string' && updateType.startsWith('replace')) {
125127
adapter.replace(newLocation);
126128
} else {
127129
adapter.push(newLocation);

0 commit comments

Comments
 (0)