Skip to content

Commit

Permalink
chore: Migrate next-usequerystate to nuqs
Browse files Browse the repository at this point in the history
- Update package name from `next-usequerystate` to `nuqs`
- Add type-safety for the 'builder' boolean search param.

Announcement about package name migration here:
47ng/nuqs#438
  • Loading branch information
franky47 committed Jan 7, 2024
1 parent ae97907 commit 0c09945
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 17 deletions.
2 changes: 1 addition & 1 deletion apps/www/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@
"next": "14.0.4",
"next-contentlayer": "0.3.4",
"next-themes": "^0.2.1",
"next-usequerystate": "^1.13.2",
"nuqs": "^1.14.0",
"prism-react-renderer": "^1.3.5",
"react": "^18.2.0",
"react-dnd": "16.0.1",
Expand Down
11 changes: 7 additions & 4 deletions apps/www/src/app/_components/home-tabs.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { useEffect } from 'react';
import dynamic from 'next/dynamic';
import { cn } from '@udecode/cn';
import { Settings2 } from 'lucide-react';
import { useQueryState } from 'next-usequerystate';
import { parseAsBoolean, useQueryState } from 'nuqs';

import { Tabs, TabsContent, TabsList, TabsTrigger } from '@/components/ui/tabs';
import { settingsStore } from '@/components/context/settings-store';
Expand All @@ -16,17 +16,20 @@ const InstallationTab = dynamic(() => import('./installation-tab'));
export default function HomeTabs() {
const active = settingsStore.use.showSettings();
const homeTab = settingsStore.use.homeTab();
const [builder, setBuilder] = useQueryState('builder');
const [builder, setBuilder] = useQueryState(
'builder',
parseAsBoolean.withDefault(false)
);

useEffect(() => {
if (builder === 'true') {
if (builder) {
settingsStore.set.showSettings(true);
}
}, [builder]);

useEffect(() => {
if (active) {
void setBuilder('true');
void setBuilder(true);
} else {
void setBuilder(null);
}
Expand Down
24 changes: 12 additions & 12 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -15782,17 +15782,6 @@ __metadata:
languageName: node
linkType: hard

"next-usequerystate@npm:^1.13.2":
version: 1.13.2
resolution: "next-usequerystate@npm:1.13.2"
dependencies:
mitt: "npm:^3.0.1"
peerDependencies:
next: ">=13.4 <14.0.2 || ^14.0.3"
checksum: 983b726ccc93abc5734773fa82c4b2d53d1cc6288bdc7e7ffb2fe1288800eafd6115ebb8d52e42a6aa0dc08f75cf3134301796f35d86c4c7c140805fc5757711
languageName: node
linkType: hard

"next@npm:14.0.4":
version: 14.0.4
resolution: "next@npm:14.0.4"
Expand Down Expand Up @@ -16055,6 +16044,17 @@ __metadata:
languageName: node
linkType: hard

"nuqs@npm:^1.14.0":
version: 1.14.0
resolution: "nuqs@npm:1.14.0"
dependencies:
mitt: "npm:^3.0.1"
peerDependencies:
next: ">=13.4 <14.0.2 || ^14.0.3"
checksum: dbc8e8223ff208e586fc9e4e8cecc83c53cd66d2969c07897f35da4908dee35e3220f584d4ca5edb73fd8703c08e73d1a525f6afc1a913383d2d6188aab169aa
languageName: node
linkType: hard

"nwsapi@npm:^2.2.2":
version: 2.2.5
resolution: "nwsapi@npm:2.2.5"
Expand Down Expand Up @@ -21678,7 +21678,7 @@ __metadata:
next: "npm:14.0.4"
next-contentlayer: "npm:0.3.4"
next-themes: "npm:^0.2.1"
next-usequerystate: "npm:^1.13.2"
nuqs: "npm:^1.14.0"
postcss: "npm:^8.4.25"
prism-react-renderer: "npm:^1.3.5"
react: "npm:^18.2.0"
Expand Down

0 comments on commit 0c09945

Please sign in to comment.