-
-
Notifications
You must be signed in to change notification settings - Fork 102
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
Migrate state management from nanostores to jotai #1022
Conversation
|
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
Warning There were issues while running some tools. Please review the errors and either fix the tool’s configuration or disable the tool if it’s a critical failure. 🔧 ESLint
apps/web/src/components/admin/admin-profile-dropdown.tsxOops! Something went wrong! :( ESLint: 9.19.0 Error: Cannot find package '/node_modules/@tszhong0411/eslint-config/dist/index.js' imported from /eslint.config.mjs apps/web/src/app/[locale]/(main)/guestbook/sign-in.tsxOops! Something went wrong! :( ESLint: 9.19.0 Error: Cannot find package '/node_modules/@tszhong0411/eslint-config/dist/index.js' imported from /eslint.config.mjs apps/web/src/components/command-menu.tsxOops! Something went wrong! :( ESLint: 9.19.0 Error: Cannot find package '/node_modules/@tszhong0411/eslint-config/dist/index.js' imported from /eslint.config.mjs
WalkthroughThe pull request transitions dialog state management from the nanostores library to the Jotai library. It updates the dependency configuration in the package file and revises several components to replace direct state modifications with atom-based functional updates. The change also involves renaming and removal of outdated state utilities in the central dialogs store. Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant Component
participant AtomStore
participant Dialog
User->>Component: Clicks "Sign In" button
Component->>AtomStore: Calls setDialogs((dialogs) => ({ ...dialogs, signIn: true }))
AtomStore-->>Dialog: Updates state (signIn: true)
Dialog->>User: Renders sign-in dialog
✨ Finishing Touches
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
Documentation and Community
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (1)
apps/web/src/store/dialogs.ts (1)
1-9
: LGTM! Clean migration to jotai.The migration follows jotai's best practices with proper type definitions and atom naming conventions.
Consider adding a brief JSDoc comment above the atom to document its purpose and usage pattern:
+/** + * Atom for managing dialog visibility states across the app. + * @example + * const setDialogs = useSetAtom(dialogsAtom) + * setDialogs((prev) => ({ ...prev, signIn: true })) + */ export const dialogsAtom = atom<Dialogs>({ signIn: false })
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (1)
pnpm-lock.yaml
is excluded by!**/pnpm-lock.yaml
📒 Files selected for processing (7)
apps/web/package.json
(1 hunks)apps/web/src/app/[locale]/(main)/guestbook/sign-in.tsx
(1 hunks)apps/web/src/components/admin/admin-profile-dropdown.tsx
(2 hunks)apps/web/src/components/command-menu.tsx
(4 hunks)apps/web/src/components/comments/unauthorized-overlay.tsx
(1 hunks)apps/web/src/components/sign-in-dialog.tsx
(2 hunks)apps/web/src/store/dialogs.ts
(1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (2)
- GitHub Check: TypeScript
- GitHub Check: ESLint
🔇 Additional comments (9)
apps/web/src/components/comments/unauthorized-overlay.tsx (1)
3-16
: LGTM! Proper state update pattern.The migration correctly uses jotai's functional update pattern to preserve existing state.
apps/web/src/app/[locale]/(main)/guestbook/sign-in.tsx (1)
5-18
: LGTM! Consistent implementation.The migration maintains consistency with other components using the same jotai patterns.
apps/web/src/components/admin/admin-profile-dropdown.tsx (1)
Line range hint
13-34
: LGTM! Migration completed successfully.The component has been properly migrated to use jotai's state management patterns.
apps/web/src/components/sign-in-dialog.tsx (3)
13-13
: LGTM! Import changes align with jotai migration.The imports have been correctly updated to use jotai instead of nanostores.
Also applies to: 18-18
50-50
: LGTM! State management correctly migrated to jotai.The implementation properly uses
useAtom
hook for accessing and updating the dialog state.
57-60
: LGTM! Dialog state updates properly implemented.The implementation correctly:
- Uses functional updates to maintain state immutability
- Preserves other dialog states using spread operator
apps/web/src/components/command-menu.tsx (2)
19-19
: LGTM! Import changes align with jotai migration.The imports have been correctly updated to use jotai's useSetAtom for write-only access to the atom state.
Also applies to: 32-32
49-49
: LGTM! Dialog state updates properly implemented.The implementation correctly:
- Uses useSetAtom for write-only access to the atom state
- Implements functional updates to maintain state immutability
- Preserves other dialog states using spread operator
Also applies to: 93-93
apps/web/package.json (1)
51-51
: LGTM! Dependencies updated for jotai migration.The package.json has been correctly updated to:
- Remove @nanostores/react dependency
- Add jotai dependency with appropriate version
Description
Migrate state management from nanostores to jotai.
Type of Change
Pre-flight Checklist
pnpm check
without any issuesSummary by CodeRabbit