From a07dada0c9ba80976692ee14e256da0a2d6b0112 Mon Sep 17 00:00:00 2001 From: nsfisis Date: Sun, 1 Feb 2026 10:16:35 +0900 Subject: refactor(atoms): migrate to jotai-tanstack-query from custom reloadable atoms Replace custom createReloadableAtom/createReloadableAtomFamily with atomWithSuspenseQuery from jotai-tanstack-query, leveraging TanStack Query's built-in caching, invalidation, and Suspense support. - Add @tanstack/query-core and jotai-tanstack-query dependencies - Create shared QueryClient instance (src/client/queryClient.ts) - Migrate all data atoms (decks, cards, study, noteTypes) to atomWithSuspenseQuery - Update page components to use .data destructuring and queryClient.invalidateQueries() - Update all test files to use QueryClient for data hydration - Remove src/client/atoms/utils.ts (no longer needed) Co-Authored-By: Claude Opus 4.5 --- pnpm-lock.yaml | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) (limited to 'pnpm-lock.yaml') diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 8b39ab9..ddba5a4 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -32,6 +32,9 @@ importers: '@hono/zod-validator': specifier: ^0.7.6 version: 0.7.6(hono@4.11.3)(zod@4.3.2) + '@tanstack/query-core': + specifier: ^5.90.20 + version: 5.90.20 argon2: specifier: ^0.44.0 version: 0.44.0 @@ -53,6 +56,9 @@ importers: jotai: specifier: ^2.16.1 version: 2.16.1(@babel/core@7.28.5)(@babel/template@7.27.2)(@types/react@19.2.7)(react@19.2.3) + jotai-tanstack-query: + specifier: ^0.11.0 + version: 0.11.0(@tanstack/query-core@5.90.20)(jotai@2.16.1(@babel/core@7.28.5)(@babel/template@7.27.2)(@types/react@19.2.7)(react@19.2.3))(react@19.2.3) pg: specifier: ^8.16.3 version: 8.16.3 @@ -1679,6 +1685,9 @@ packages: peerDependencies: vite: ^5.2.0 || ^6 || ^7 + '@tanstack/query-core@5.90.20': + resolution: {integrity: sha512-OMD2HLpNouXEfZJWcKeVKUgQ5n+n3A2JFmBaScpNDUqSrQSjiveC7dKMe53uJUg1nDG16ttFPz2xfilz6i2uVg==} + '@testing-library/dom@10.4.1': resolution: {integrity: sha512-o4PXJQidqJl82ckFaXUeoAW+XysPLauYI43Abki5hABd853iMhitooc6znOnczgbTYmEP6U6/y1ZyKAIsvMKGg==} engines: {node: '>=18'} @@ -2502,6 +2511,19 @@ packages: resolution: {integrity: sha512-ekilCSN1jwRvIbgeg/57YFh8qQDNbwDb9xT/qu2DAHbFFZUicIl4ygVaAvzveMhMVr3LnpSKTNnwt8PoOfmKhQ==} hasBin: true + jotai-tanstack-query@0.11.0: + resolution: {integrity: sha512-Ys0u0IuuS6/okUJOulFTdCVfVaeKbm1+lKVSN9zHhIxtrAXl9FM4yu7fNvxM6fSz/NCE9tZOKR0MQ3hvplaH8A==} + peerDependencies: + '@tanstack/query-core': '*' + '@tanstack/react-query': '*' + jotai: '>=2.0.0' + react: ^18.0.0 || ^19.0.0 + peerDependenciesMeta: + '@tanstack/react-query': + optional: true + react: + optional: true + jotai@2.16.1: resolution: {integrity: sha512-vrHcAbo3P7Br37C8Bv6JshMtlKMPqqmx0DDREtTjT4nf3QChDrYdbH+4ik/9V0cXA57dK28RkJ5dctYvavcIlg==} engines: {node: '>=12.20.0'} @@ -4789,6 +4811,8 @@ snapshots: tailwindcss: 4.1.18 vite: 7.3.0(@types/node@24.10.4)(jiti@2.6.1)(lightningcss@1.30.2)(terser@5.44.1) + '@tanstack/query-core@5.90.20': {} + '@testing-library/dom@10.4.1': dependencies: '@babel/code-frame': 7.27.1 @@ -5681,6 +5705,13 @@ snapshots: jiti@2.6.1: {} + jotai-tanstack-query@0.11.0(@tanstack/query-core@5.90.20)(jotai@2.16.1(@babel/core@7.28.5)(@babel/template@7.27.2)(@types/react@19.2.7)(react@19.2.3))(react@19.2.3): + dependencies: + '@tanstack/query-core': 5.90.20 + jotai: 2.16.1(@babel/core@7.28.5)(@babel/template@7.27.2)(@types/react@19.2.7)(react@19.2.3) + optionalDependencies: + react: 19.2.3 + jotai@2.16.1(@babel/core@7.28.5)(@babel/template@7.27.2)(@types/react@19.2.7)(react@19.2.3): optionalDependencies: '@babel/core': 7.28.5 -- cgit v1.3-1-g0d28