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

feat: update nuqs #544

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 2 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
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@
"lucia": "3.2.0",
"next": "14.2.4",
"nodemailer": "6.9.14",
"nuqs": "1.17.4",
"nuqs": "2.0.4",
"oslo": "1.2.1",
"pino": "9.2.0",
"pino-pretty": "11.2.1",
Expand Down
43 changes: 28 additions & 15 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 8 additions & 5 deletions src/app/Document.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { ReactNode } from 'react';

import { ColorModeScript } from '@chakra-ui/react';
import { ReactQueryDevtools } from '@tanstack/react-query-devtools';
import { NuqsAdapter } from 'nuqs/adapters/next/app';

import { Providers } from '@/app/Providers';
import { Viewport } from '@/components/Viewport';
Expand Down Expand Up @@ -63,11 +64,13 @@ export const Document = ({ children }: { children: ReactNode }) => {
storageKey={COLOR_MODE_STORAGE_KEY}
/>
<Providers>
<TrpcProvider>
<Viewport>{children}</Viewport>
<EnvHint />
<ReactQueryDevtools initialIsOpen={false} />
</TrpcProvider>
<NuqsAdapter>
<TrpcProvider>
<Viewport>{children}</Viewport>
<EnvHint />
<ReactQueryDevtools initialIsOpen={false} />
</TrpcProvider>
</NuqsAdapter>
</Providers>
</body>
</html>
Expand Down
6 changes: 1 addition & 5 deletions src/features/account/AccountDeleteVerificationCodeModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,7 @@ export const AccountDeleteVerificationCodeModale = () => {
);

const onClose = () => {
setSearchParams({
[SEARCH_PARAM_VERIFY_EMAIL]: null,
token: null,
attempts: null,
});
setSearchParams(null);
};

const form = useForm<FormFieldsVerificationCode>({
Expand Down
6 changes: 1 addition & 5 deletions src/features/account/EmailVerificationCodeModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,7 @@ export const EmailVerificationCodeModale = () => {

const onClose = () => {
trpcUtils.account.get.reset();
setSearchParams({
verifyEmail: null,
token: null,
attempts: null,
});
setSearchParams(null);
Copy link
Contributor

Choose a reason for hiding this comment

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

💡 Codebase verification

Migration to nuqs v2 requires consistent updates across all files

Based on the search results, there are several files using nuqs that need consistent updates for v2 compatibility:

  • src/features/account/AccountDeleteVerificationCodeModal.tsx: Uses useQueryStates and setSearchParams(null)
  • src/features/account/AccountEmailForm.tsx: Uses useQueryStates with object parameter setting
  • src/features/account/AccountDeleteButton.tsx: Uses useQueryStates with object parameter setting
  • src/features/users/PageAdminUsers.tsx: Uses useQueryState (singular)
  • src/features/repositories/PageAdminRepositories.tsx: Uses useQueryState (singular)
  • src/features/auth/VerificationCodeForm.tsx: Uses useQueryState (singular)

The current change to setSearchParams(null) is correct for nuqs v2, but other files still use v1 patterns. Key changes needed:

  • Files using useQueryState (singular) should be reviewed as the API might have changed
  • Object parameter setting syntax in AccountEmailForm and AccountDeleteButton should be verified against v2 docs
🔗 Analysis chain

Verify the nuqs v2 migration.

The change to setSearchParams(null) aligns with nuqs v2's API for resetting all search parameters. However, let's verify there are no other nuqs v2 migration requirements.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check for any other nuqs usage patterns that might need updates
# Look for other nuqs imports and usage patterns that might need migration

# Search for all nuqs imports
echo "Checking nuqs imports:"
rg "from 'nuqs'" -A 2

# Search for setSearchParams usage
echo "Checking setSearchParams usage:"
rg "setSearchParams" -A 2

# Search for useQueryStates usage
echo "Checking useQueryStates usage:"
rg "useQueryStates" -A 2

Length of output: 6651

};

const form = useForm<FormFieldsVerificationCode>({
Expand Down
Loading