Skip to content

feat(stores/global): use jotai #3134

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

SkyeYoung
Copy link
Member

@SkyeYoung SkyeYoung commented Jun 29, 2025

Please answer these questions before submitting a pull request, or your PR will get closed.

Why submit this pull request?

  • Bugfix
  • New feature provided
  • Improve performance
  • Backport patches

What changes will this PR take into?

MobX lacks maintenance and is not compatible with react compiler.

CleanShot 2025-06-29 at 14 17 18@2x

I want to replace MobX with a more active library.

First change the simple use case global store to use jotai.

@SkyeYoung SkyeYoung marked this pull request as ready for review July 1, 2025 03:02
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

Migrates global state management from MobX to Jotai, replacing observable stores with atoms and updating components and axios interceptors to use the new state.

  • Introduces adminKeyAtom and isSettingsOpenAtom in src/stores/global.ts
  • Updates axios request/response interceptors to read/write atoms via getDefaultStore
  • Refactors SettingsModal, AdminKey, and trigger button to use Jotai hooks

Reviewed Changes

Copilot reviewed 5 out of 6 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
src/stores/global.ts Replaced MobX observable store with Jotai atoms for admin key persistence and settings visibility
src/config/req.ts Switched axios interceptors from MobX store to Jotai atoms using getDefaultStore
src/components/page/SettingsModal.tsx Refactored modal and input to use useAtom hooks instead of MobX
src/components/Header/SettingModalBtn.tsx Updated settings button to use useSetAtom for opening modal
package.json Added jotai dependency; MobX dependencies remain
Files not reviewed (1)
  • pnpm-lock.yaml: Language not supported
Comments suppressed due to low confidence (2)

src/components/Header/SettingModalBtn.tsx:23

  • [nitpick] Component and file name use singular SettingModalBtn while the modal is SettingsModal. Consider renaming to SettingsModalBtn for consistency.
export const SettingModalBtn = () => {

src/stores/global.ts:21

  • New atoms (adminKeyAtom, isSettingsOpenAtom) introduce critical state behavior. Consider adding unit tests to verify persistence and default values.
export const adminKeyAtom = atomWithStorage<string>(

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants