Skip to content
Open
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
Copy link

@kss2002 kss2002 Nov 28, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hello πŸ‘‹
You changed the call _setCardId from object to primitive

// previous
_setCardId({ cardId }, "replaceIn");

// updated
_setCardId(cardId, "replaceIn");

This may change the shape of the query parameter and could affect existing behavior or consumers that expect the object form.

Can you confirm that this change is intentional and aligned with how useQueryParam + NumberParam are expected to work?

I think updating the dependency array to include _setCardId is a good improvement!

Thank you :)

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the review and for pointing this out!

In this case, the change was intentional.
Since useQueryParam("cardId", NumberParam) is used, the setter returned by useQueryParam expects a primitive number, not an object. Passing { cardId } was causing a mismatch with how NumberParam serializes the value, and could result in an incorrect query parameter shape.

Therefore, _setCardId(cardId, "replaceIn") is the correct usage aligned with the expected behavior of useQueryParam + NumberParam.

Thanks again for the thoughtful review!

#76 (comment)

If I’m mistaken in any way, please don’t hesitate to let me know!

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for your answer.

I wrote a review considering the influence of other documents.
I think it's a good contribution given that it's a deliberate change.

Thank you :)

Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,12 @@ import { NumberParam, useQueryParam } from "use-query-params";
export function useCardIdQueryParam() {
const [cardId, _setCardId] = useQueryParam("cardId", NumberParam);

const setCardId = useCallback((cardId: number) => {
_setCardId({ cardId }, "replaceIn");
}, []);
const setCardId = useCallback(
(cardId: number) => {
_setCardId(cardId, "replaceIn");
},
[_setCardId]
);

return [cardId ?? undefined, setCardId] as const;
}
Expand Down