Skip to content

Commit cf5e4cb

Browse files
committed
feat(web): add @reactuses/core and reorganize atoms
- Install @reactuses/core for React hooks (13.2 KB gzip, React 19 support) - Create theme-atoms.ts (separate themeAtom from user-atoms) - Create location-atoms.ts (useLocation from jotai-location) - Update user-atoms.ts (remove themeAtom, add debugLabels)
1 parent 9359146 commit cf5e4cb

5 files changed

Lines changed: 149 additions & 3 deletions

File tree

apps/web/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
"@opentelemetry/sdk-node": "^0.208.0",
2525
"@opentelemetry/sdk-trace-base": "^2.2.0",
2626
"@opentelemetry/semantic-conventions": "^1.38.0",
27+
"@reactuses/core": "^6.1.8",
2728
"@serwist/turbopack": "^9.5.0",
2829
"@tanstack/react-devtools": "^0.9.1",
2930
"@tanstack/react-form": "^1.27.7",

apps/web/pnpm-lock.yaml

Lines changed: 115 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import { atomWithLocation } from "jotai-location";
2+
3+
/**
4+
* Location atom that syncs with window.location
5+
* Provides access to pathname, search params, and hash
6+
*
7+
* @example
8+
* ```tsx
9+
* const [location, setLocation] = useAtom(locationAtom);
10+
*
11+
* // Read current location
12+
* console.log(location.pathname);
13+
* console.log(location.searchParams?.get('query'));
14+
*
15+
* // Update location
16+
* setLocation((prev) => ({
17+
* ...prev,
18+
* pathname: '/new-path',
19+
* searchParams: new URLSearchParams([['key', 'value']])
20+
* }));
21+
* ```
22+
*/
23+
export const locationAtom = atomWithLocation();
24+
25+
locationAtom.debugLabel = "location";

apps/web/src/stores/theme-atoms.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import { atomWithStorage } from "jotai/utils";
2+
3+
export const themeAtom = atomWithStorage<"light" | "dark" | "system">("theme", "system");
4+
5+
themeAtom.debugLabel = "theme";

apps/web/src/stores/user-atoms.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
11
import { atom } from "jotai";
2-
import { atomWithStorage } from "jotai/utils";
3-
4-
export const themeAtom = atomWithStorage<"light" | "dark" | "system">("theme", "system");
52

63
interface User {
74
id: string;
@@ -11,3 +8,6 @@ interface User {
118

129
export const userAtom = atom<User | null>(null);
1310
export const isLoggedInAtom = atom((get) => get(userAtom) !== null);
11+
12+
userAtom.debugLabel = "user";
13+
isLoggedInAtom.debugLabel = "isLoggedIn";

0 commit comments

Comments
 (0)