docs-i18n 0.8.1 → 0.8.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/admin/dist/server/server.js +32 -32
- package/package.json +1 -1
- package/template/app/routes/$lang.$project.$version.docs.$.tsx +2 -1
- package/template/app/routes/$lang.$project.$version.docs.framework.$framework.$.tsx +2 -0
- package/template/app/routes/$lang.$project.$version.docs.tsx +2 -1
- package/template/app/routes/$lang.$project.docs.$.tsx +2 -1
- package/template/app/routes/$lang.$project.docs.tsx +2 -1
- package/template/app/routes/$lang.docs.$.tsx +2 -1
- package/template/app/routes/$lang.docs.framework.$framework.$.tsx +2 -0
- package/template/app/routes/$lang.docs.tsx +2 -1
- package/template/app/utils/content-loader.ts +13 -2
- package/template/app/utils/docs.server.ts +17 -15
- package/template/content/blog/en/announcing-query-v5.md +110 -0
- package/template/content/blog/en/hello-world.md +26 -0
- package/template/content/blog/en/i18n-best-practices.md +57 -0
- package/template/content/blog/en/react-query-vs-swr.md +100 -0
- package/template/content/blog/en/state-management-2024.md +143 -0
- package/template/content/blog/en/tanstack-router-1.0.md +121 -0
- package/template/content/blog/ja/announcing-query-v5.md +110 -0
- package/template/content/blog/ja/hello-world.md +26 -0
- package/template/content/blog/zh-hans/announcing-query-v5.md +93 -0
- package/template/content/blog/zh-hans/hello-world.md +26 -0
- package/template/content/docs-i18n/docs.config.json +25 -0
- package/template/content/docs-i18n/en/architecture.md +335 -0
- package/template/content/docs-i18n/en/cli.md +13 -1
- package/template/content/docs-i18n/en/configuration.md +350 -0
- package/template/content/docs-i18n/en/deployment.md +222 -0
- package/template/content/docs-i18n/en/getting-started.md +189 -0
- package/template/content/docs.config.json +25 -0
- package/template/content/en/admin.md +151 -0
- package/template/content/en/architecture.md +222 -0
- package/template/content/en/cli.md +269 -0
- package/template/content/en/configuration.md +331 -0
- package/template/content/en/deployment.md +209 -0
- package/template/content/en/getting-started.md +168 -0
- package/template/content/form/docs.config.json +18 -0
- package/template/content/form/en/guides/validation.md +175 -0
- package/template/content/form/en/installation.md +63 -0
- package/template/content/form/en/overview.md +71 -0
- package/template/content/form/en/quick-start.md +121 -0
- package/template/content/form/ja/installation.md +63 -0
- package/template/content/form/ja/overview.md +71 -0
- package/template/content/form/zh-hans/installation.md +63 -0
- package/template/content/form/zh-hans/overview.md +71 -0
- package/template/content/query/docs.config.json +32 -0
- package/template/content/query/en/guides/mutations.md +126 -0
- package/template/content/query/en/guides/pagination.md +98 -0
- package/template/content/query/en/guides/queries.md +120 -0
- package/template/content/query/en/installation.md +78 -0
- package/template/content/query/en/overview.md +72 -0
- package/template/content/query/en/quick-start.md +108 -0
- package/template/content/query/ja/installation.md +78 -0
- package/template/content/query/ja/overview.md +72 -0
- package/template/content/query/zh-hans/guides/mutations.md +126 -0
- package/template/content/query/zh-hans/guides/pagination.md +98 -0
- package/template/content/query/zh-hans/guides/queries.md +120 -0
- package/template/content/query/zh-hans/installation.md +95 -0
- package/template/content/query/zh-hans/overview.md +72 -0
- package/template/content/query/zh-hans/quick-start.md +108 -0
- package/template/content/router/docs.config.json +18 -0
- package/template/content/router/en/guides/routing-concepts.md +131 -0
- package/template/content/router/en/installation.md +57 -0
- package/template/content/router/en/overview.md +74 -0
- package/template/content/router/en/quick-start.md +88 -0
- package/template/content/router/ja/installation.md +57 -0
- package/template/content/router/ja/overview.md +78 -0
- package/template/content/router/zh-hans/guides/routing-concepts.md +131 -0
- package/template/content/router/zh-hans/installation.md +57 -0
- package/template/content/router/zh-hans/overview.md +81 -0
- package/template/content/router/zh-hans/quick-start.md +88 -0
- package/template/content/table/docs.config.json +18 -0
- package/template/content/table/en/guides/column-definitions.md +135 -0
- package/template/content/table/en/installation.md +56 -0
- package/template/content/table/en/overview.md +79 -0
- package/template/content/table/en/quick-start.md +112 -0
- package/template/content/table/ja/installation.md +56 -0
- package/template/content/table/ja/overview.md +79 -0
- package/template/content/table/zh-hans/installation.md +56 -0
- package/template/content/table/zh-hans/overview.md +79 -0
- package/template/content/virtual/docs.config.json +18 -0
- package/template/content/virtual/en/guides/dynamic-sizing.md +129 -0
- package/template/content/virtual/en/installation.md +57 -0
- package/template/content/virtual/en/overview.md +74 -0
- package/template/content/virtual/en/quick-start.md +114 -0
- package/template/content/virtual/ja/installation.md +57 -0
- package/template/content/virtual/ja/overview.md +74 -0
- package/template/content/virtual/zh-hans/installation.md +57 -0
- package/template/content/virtual/zh-hans/overview.md +74 -0
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: "The State of State Management in 2024"
|
|
3
|
+
published: "2024-08-20"
|
|
4
|
+
excerpt: "Server state vs client state, signals vs hooks, atoms vs stores — a practical guide to choosing the right state management approach for your React application in 2024."
|
|
5
|
+
authors:
|
|
6
|
+
- "docs-i18n Team"
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
State management in React has evolved dramatically. The days of putting everything in Redux are over. In 2024, the ecosystem has matured into a set of specialized tools, each solving a specific problem well.
|
|
10
|
+
|
|
11
|
+
## The Two Kinds of State
|
|
12
|
+
|
|
13
|
+
The most important mental model shift in modern state management is the distinction between **server state** and **client state**.
|
|
14
|
+
|
|
15
|
+
**Server state** is data that:
|
|
16
|
+
- Lives on the server / database
|
|
17
|
+
- Is fetched asynchronously
|
|
18
|
+
- Can become stale
|
|
19
|
+
- Is shared across users
|
|
20
|
+
|
|
21
|
+
**Client state** is data that:
|
|
22
|
+
- Exists only in the browser
|
|
23
|
+
- Is synchronous
|
|
24
|
+
- Is local to the user's session
|
|
25
|
+
- Examples: UI toggles, form inputs, selected tabs
|
|
26
|
+
|
|
27
|
+
```tsx
|
|
28
|
+
// Server state — use TanStack Query
|
|
29
|
+
const { data: todos } = useQuery({
|
|
30
|
+
queryKey: ['todos'],
|
|
31
|
+
queryFn: fetchTodos,
|
|
32
|
+
})
|
|
33
|
+
|
|
34
|
+
// Client state — use React state or a small store
|
|
35
|
+
const [isOpen, setIsOpen] = useState(false)
|
|
36
|
+
const [selectedTab, setSelectedTab] = useState('all')
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
> [!NOTE]
|
|
40
|
+
> If you separate server state from client state, you will find that most applications need very little client state management. TanStack Query (or a similar library) handles the majority of your state.
|
|
41
|
+
|
|
42
|
+
## Server State Libraries
|
|
43
|
+
|
|
44
|
+
### TanStack Query
|
|
45
|
+
|
|
46
|
+
The most feature-rich option for server state management. Provides caching, background refetching, mutations with optimistic updates, pagination, infinite scroll, and excellent devtools.
|
|
47
|
+
|
|
48
|
+
```tsx
|
|
49
|
+
import { useQuery, useMutation, useQueryClient } from '@tanstack/react-query'
|
|
50
|
+
|
|
51
|
+
function TodoApp() {
|
|
52
|
+
const queryClient = useQueryClient()
|
|
53
|
+
const todos = useQuery({ queryKey: ['todos'], queryFn: fetchTodos })
|
|
54
|
+
|
|
55
|
+
const addTodo = useMutation({
|
|
56
|
+
mutationFn: createTodo,
|
|
57
|
+
onSuccess: () => queryClient.invalidateQueries({ queryKey: ['todos'] }),
|
|
58
|
+
})
|
|
59
|
+
|
|
60
|
+
return (
|
|
61
|
+
<div>
|
|
62
|
+
{todos.data?.map((todo) => <Todo key={todo.id} todo={todo} />)}
|
|
63
|
+
<button onClick={() => addTodo.mutate({ title: 'New' })}>Add</button>
|
|
64
|
+
</div>
|
|
65
|
+
)
|
|
66
|
+
}
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
### SWR
|
|
70
|
+
|
|
71
|
+
A lighter alternative focused on data fetching. Smaller bundle, simpler API, fewer features.
|
|
72
|
+
|
|
73
|
+
### tRPC
|
|
74
|
+
|
|
75
|
+
End-to-end type-safe APIs. Built on top of TanStack Query, so you get all its caching benefits plus type-safe API calls.
|
|
76
|
+
|
|
77
|
+
## Client State Libraries
|
|
78
|
+
|
|
79
|
+
### React `useState` / `useReducer`
|
|
80
|
+
|
|
81
|
+
For most client state, built-in React state is sufficient. Do not reach for a library until you have a clear need.
|
|
82
|
+
|
|
83
|
+
### Zustand
|
|
84
|
+
|
|
85
|
+
When you need global client state (theme, user preferences, complex UI state), Zustand provides a minimal, hook-based API:
|
|
86
|
+
|
|
87
|
+
```tsx
|
|
88
|
+
import { create } from 'zustand'
|
|
89
|
+
|
|
90
|
+
const useStore = create((set) => ({
|
|
91
|
+
bears: 0,
|
|
92
|
+
increasePopulation: () => set((state) => ({ bears: state.bears + 1 })),
|
|
93
|
+
}))
|
|
94
|
+
|
|
95
|
+
function BearCounter() {
|
|
96
|
+
const bears = useStore((state) => state.bears)
|
|
97
|
+
return <h1>{bears} bears</h1>
|
|
98
|
+
}
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
### Jotai
|
|
102
|
+
|
|
103
|
+
Atomic state management inspired by Recoil. Great for fine-grained reactivity:
|
|
104
|
+
|
|
105
|
+
```tsx
|
|
106
|
+
import { atom, useAtom } from 'jotai'
|
|
107
|
+
|
|
108
|
+
const countAtom = atom(0)
|
|
109
|
+
const doubledAtom = atom((get) => get(countAtom) * 2)
|
|
110
|
+
|
|
111
|
+
function Counter() {
|
|
112
|
+
const [count, setCount] = useAtom(countAtom)
|
|
113
|
+
const [doubled] = useAtom(doubledAtom)
|
|
114
|
+
return <div>{count} (doubled: {doubled})</div>
|
|
115
|
+
}
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
## Decision Framework
|
|
119
|
+
|
|
120
|
+
| Need | Recommended Tool |
|
|
121
|
+
|---|---|
|
|
122
|
+
| Fetching / caching server data | TanStack Query or SWR |
|
|
123
|
+
| Local component state | `useState` / `useReducer` |
|
|
124
|
+
| Shared UI state (theme, modals) | Zustand or Jotai |
|
|
125
|
+
| Complex form state | TanStack Form |
|
|
126
|
+
| URL state (search params, pagination) | TanStack Router |
|
|
127
|
+
| End-to-end type-safe API | tRPC + TanStack Query |
|
|
128
|
+
|
|
129
|
+
## The Pattern
|
|
130
|
+
|
|
131
|
+
The most successful React applications in 2024 follow this pattern:
|
|
132
|
+
|
|
133
|
+
1. **TanStack Query** for all server state
|
|
134
|
+
2. **TanStack Router** for URL-driven state
|
|
135
|
+
3. **React `useState`** for local UI state
|
|
136
|
+
4. **Zustand or Jotai** (only if needed) for global client state
|
|
137
|
+
|
|
138
|
+
> [!WARNING]
|
|
139
|
+
> Avoid putting server data in a global client state store (Redux, Zustand, etc.). This leads to stale data, duplicated caching logic, and unnecessary complexity. Use TanStack Query for server state.
|
|
140
|
+
|
|
141
|
+
## Conclusion
|
|
142
|
+
|
|
143
|
+
State management in 2024 is not about choosing one library to rule them all. It is about using the right tool for the right kind of state. Start simple, add complexity only when needed, and let specialized libraries handle what they do best.
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: "TanStack Router 1.0: Type-Safe Routing for React"
|
|
3
|
+
published: "2024-03-15"
|
|
4
|
+
excerpt: "TanStack Router 1.0 is stable! With 100% type-safe navigation, built-in search params, and first-class data loading, it is the most type-safe router for React."
|
|
5
|
+
authors:
|
|
6
|
+
- "Tanner Linsley"
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
After years of development and months of beta testing, we are proud to announce TanStack Router 1.0 is stable and production-ready.
|
|
10
|
+
|
|
11
|
+
## Why Another Router?
|
|
12
|
+
|
|
13
|
+
React Router has served the community well for years. But as TypeScript adoption has grown, developers have increasingly wanted a router that provides end-to-end type safety. TanStack Router was built from the ground up with TypeScript as a first-class citizen.
|
|
14
|
+
|
|
15
|
+
## Key Features
|
|
16
|
+
|
|
17
|
+
### 100% Type-Safe Navigation
|
|
18
|
+
|
|
19
|
+
Every `Link`, `navigate`, and `redirect` in TanStack Router is fully type-checked:
|
|
20
|
+
|
|
21
|
+
```tsx
|
|
22
|
+
// TypeScript will error if:
|
|
23
|
+
// - The route does not exist
|
|
24
|
+
// - Required params are missing
|
|
25
|
+
// - Search params do not match the schema
|
|
26
|
+
<Link
|
|
27
|
+
to="/users/$userId/posts/$postId"
|
|
28
|
+
params={{ userId: '1', postId: '42' }}
|
|
29
|
+
search={{ sort: 'date' }}
|
|
30
|
+
/>
|
|
31
|
+
|
|
32
|
+
// This would be a type error:
|
|
33
|
+
<Link
|
|
34
|
+
to="/users/$userId/posts/$postId"
|
|
35
|
+
params={{ userId: '1' }} // Error: missing postId
|
|
36
|
+
/>
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
### First-Class Search Params
|
|
40
|
+
|
|
41
|
+
URL search parameters are validated and typed:
|
|
42
|
+
|
|
43
|
+
```tsx
|
|
44
|
+
const productsRoute = createRoute({
|
|
45
|
+
path: '/products',
|
|
46
|
+
validateSearch: z.object({
|
|
47
|
+
page: z.number().default(1),
|
|
48
|
+
category: z.string().optional(),
|
|
49
|
+
sort: z.enum(['price', 'name', 'rating']).default('name'),
|
|
50
|
+
}),
|
|
51
|
+
})
|
|
52
|
+
|
|
53
|
+
// In your component:
|
|
54
|
+
const { page, category, sort } = productsRoute.useSearch()
|
|
55
|
+
// ^ All fully typed!
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
### Built-In Data Loading
|
|
59
|
+
|
|
60
|
+
No need for separate data fetching libraries for route-level data:
|
|
61
|
+
|
|
62
|
+
```tsx
|
|
63
|
+
const userRoute = createRoute({
|
|
64
|
+
path: '/users/$userId',
|
|
65
|
+
loader: async ({ params, context }) => {
|
|
66
|
+
return context.queryClient.ensureQueryData({
|
|
67
|
+
queryKey: ['user', params.userId],
|
|
68
|
+
queryFn: () => fetchUser(params.userId),
|
|
69
|
+
})
|
|
70
|
+
},
|
|
71
|
+
})
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
### File-Based Routing
|
|
75
|
+
|
|
76
|
+
For larger applications, file-based routing generates the type-safe route tree automatically:
|
|
77
|
+
|
|
78
|
+
```
|
|
79
|
+
routes/
|
|
80
|
+
__root.tsx
|
|
81
|
+
index.tsx
|
|
82
|
+
about.tsx
|
|
83
|
+
users.tsx
|
|
84
|
+
users.$userId.tsx
|
|
85
|
+
users.$userId.posts.tsx
|
|
86
|
+
users.$userId.posts.$postId.tsx
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
The router plugin generates a `routeTree.gen.ts` file with complete type information.
|
|
90
|
+
|
|
91
|
+
## Migration from React Router
|
|
92
|
+
|
|
93
|
+
We understand that migrating routers is a significant effort. We have published a detailed [migration guide](/en/router/docs/guides/migration-from-react-router) and built a codemod to help:
|
|
94
|
+
|
|
95
|
+
```bash
|
|
96
|
+
npx @tanstack/router-codemod from-react-router ./src
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
## Performance
|
|
100
|
+
|
|
101
|
+
TanStack Router is designed for performance:
|
|
102
|
+
|
|
103
|
+
- **Route-level code splitting** works out of the box with file-based routing
|
|
104
|
+
- **Prefetching** on link hover ensures instant navigations
|
|
105
|
+
- **Parallel data loading** fetches data for all matched routes simultaneously
|
|
106
|
+
- **Stale-while-revalidate** keeps the UI responsive during refetches
|
|
107
|
+
|
|
108
|
+
> [!NOTE]
|
|
109
|
+
> TanStack Router pairs beautifully with TanStack Query. Use the router for route-level data loading and Query for component-level data fetching.
|
|
110
|
+
|
|
111
|
+
## Get Started
|
|
112
|
+
|
|
113
|
+
Install TanStack Router today:
|
|
114
|
+
|
|
115
|
+
```bash
|
|
116
|
+
npm install @tanstack/react-router @tanstack/router-plugin
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
Read the [quick start guide](/en/router/docs/quick-start) to build your first type-safe route.
|
|
120
|
+
|
|
121
|
+
Thank you to everyone who contributed during the alpha and beta phases. Your feedback shaped this release into something we are truly proud of.
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: "TanStack Query v5 のリリースを発表"
|
|
3
|
+
published: "2024-10-01"
|
|
4
|
+
excerpt: "TanStack Query v5 が登場しました。シンプルになった API、強化された TypeScript サポート、改善された devtools、そしてより小さなバンドルサイズを実現しています。"
|
|
5
|
+
authors:
|
|
6
|
+
- "Tanner Linsley"
|
|
7
|
+
- "Dominik Dorfmeister"
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
TanStack Query v5 のリリースを発表できることを大変嬉しく思います!このリリースはコミュニティの数ヶ月にわたる作業の成果であり、全体的に大幅な改善をもたらします。
|
|
11
|
+
|
|
12
|
+
## 新機能
|
|
13
|
+
|
|
14
|
+
### シンプルになった API
|
|
15
|
+
|
|
16
|
+
v5 で最も目に見える変更はシンプルになった API です。オブジェクト構文のオーバーロードを廃止し、すべてのフックで単一の一貫したオブジェクト構文を採用しました:
|
|
17
|
+
|
|
18
|
+
```tsx
|
|
19
|
+
// v4 — 複数のオーバーロード
|
|
20
|
+
useQuery(['todos'], fetchTodos)
|
|
21
|
+
useQuery(['todos'], fetchTodos, { staleTime: 5000 })
|
|
22
|
+
useQuery({ queryKey: ['todos'], queryFn: fetchTodos })
|
|
23
|
+
|
|
24
|
+
// v5 — 単一の一貫した API
|
|
25
|
+
useQuery({
|
|
26
|
+
queryKey: ['todos'],
|
|
27
|
+
queryFn: fetchTodos,
|
|
28
|
+
staleTime: 5000,
|
|
29
|
+
})
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
これにより API の学習が容易になり、TypeScript の推論も向上しました。
|
|
33
|
+
|
|
34
|
+
### TypeScript サポートの強化
|
|
35
|
+
|
|
36
|
+
v5 には TypeScript の大幅な改善が含まれています:
|
|
37
|
+
|
|
38
|
+
- **厳密なクエリキーの型付け** — クエリキーが全体を通じて厳密に型付けされるようになりました
|
|
39
|
+
- **推論される戻り値の型** — `useQuery` が `queryFn` から戻り値の型を正しく推論します
|
|
40
|
+
- **型安全なエラーハンドリング** — 新しい `Error` ジェネリックパラメータによりエラーが適切に型付けされます
|
|
41
|
+
|
|
42
|
+
```tsx
|
|
43
|
+
// エラーの型が推論され、型安全になります
|
|
44
|
+
const { data, error } = useQuery({
|
|
45
|
+
queryKey: ['user', userId],
|
|
46
|
+
queryFn: async () => {
|
|
47
|
+
const res = await fetch(`/api/users/${userId}`)
|
|
48
|
+
if (!res.ok) throw new ApiError(res.status, await res.text())
|
|
49
|
+
return res.json() as Promise<User>
|
|
50
|
+
},
|
|
51
|
+
})
|
|
52
|
+
|
|
53
|
+
// error は ApiError | null として型付けされます
|
|
54
|
+
if (error) {
|
|
55
|
+
console.log(error.status) // TypeScript はこれが存在することを知っています
|
|
56
|
+
}
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
### 新しい Devtools
|
|
60
|
+
|
|
61
|
+
Devtools は新しいデザイン、パフォーマンスの向上、新機能で完全に書き直されました:
|
|
62
|
+
|
|
63
|
+
- **クエリタイムライン** — 時間経過によるクエリフェッチの可視化
|
|
64
|
+
- **ミューテーションインスペクター** — ミューテーションの状態と変数を検査
|
|
65
|
+
- **キャッシュエクスプローラー** — クエリキャッシュ全体をブラウズ
|
|
66
|
+
- **オンライン/オフライン切替** — オフライン動作のテスト
|
|
67
|
+
|
|
68
|
+
### バンドルサイズの削減
|
|
69
|
+
|
|
70
|
+
ツリーシェイキングの改善と非推奨 API の削除により、コアバンドルサイズを約 20% 削減しました。
|
|
71
|
+
|
|
72
|
+
| パッケージ | v4 | v5 | 変化 |
|
|
73
|
+
|---|---|---|---|
|
|
74
|
+
| `@tanstack/react-query` | 12.4 KB | 9.8 KB | -21% |
|
|
75
|
+
| `@tanstack/query-core` | 10.1 KB | 8.2 KB | -19% |
|
|
76
|
+
|
|
77
|
+
## 破壊的変更
|
|
78
|
+
|
|
79
|
+
> [!WARNING]
|
|
80
|
+
> v5 にはいくつかの破壊的変更が含まれています。アップグレード前に完全な[マイグレーションガイド](/ja/query/docs/guides/migration-v5)をご確認ください。
|
|
81
|
+
|
|
82
|
+
主な破壊的変更:
|
|
83
|
+
|
|
84
|
+
1. **オーバーロードシグネチャの廃止** — すべてのフックがオブジェクトのみの構文を使用
|
|
85
|
+
2. **`cacheTime` を `gcTime` にリネーム** — その目的(ガベージコレクション時間)をより適切に反映
|
|
86
|
+
3. **`status: 'loading'` を `status: 'pending'` にリネーム** — Promise の用語に合わせて
|
|
87
|
+
4. **`keepPreviousData` の廃止** — `placeholderData: keepPreviousData`(query core からインポート)に置き換え
|
|
88
|
+
5. **TypeScript の最低バージョンが 4.7 に**
|
|
89
|
+
|
|
90
|
+
## マイグレーション
|
|
91
|
+
|
|
92
|
+
マイグレーションの大部分を自動化する codemod を用意しています:
|
|
93
|
+
|
|
94
|
+
```bash
|
|
95
|
+
npx @tanstack/query-codemod v5 ./src
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
これにより最も一般的な変換が自動的に行われます。変更内容を確認し、十分にテストしてください。
|
|
99
|
+
|
|
100
|
+
## ありがとうございます
|
|
101
|
+
|
|
102
|
+
このリリースを可能にしてくれた 100 人以上のコントリビューターに感謝します。TanStack Query v5 は、素晴らしいオープンソースコミュニティなしには実現できませんでした。
|
|
103
|
+
|
|
104
|
+
今すぐ v5 を始めましょう:
|
|
105
|
+
|
|
106
|
+
```bash
|
|
107
|
+
npm install @tanstack/react-query@latest
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
Happy querying!
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: "Hello World:docs-i18n ブログの紹介"
|
|
3
|
+
published: "2024-01-15"
|
|
4
|
+
excerpt: "docs-i18n ブログへようこそ!プロジェクトの更新情報、チュートリアル、ドキュメント国際化のベストプラクティスを共有します。"
|
|
5
|
+
authors:
|
|
6
|
+
- "docs-i18n Team"
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
docs-i18n ブログへようこそ!ここでは、プロジェクトの更新情報、チュートリアル、ドキュメント国際化のベストプラクティスを共有します。
|
|
10
|
+
|
|
11
|
+
## docs-i18n とは?
|
|
12
|
+
|
|
13
|
+
docs-i18n は、多言語ドキュメントサイトを簡単に維持できるようにする汎用ドキュメント翻訳エンジンです。以下を提供します:
|
|
14
|
+
|
|
15
|
+
- **ファイルシステムベースのコンテンツ読み込み**(i18n フォールバック付き)
|
|
16
|
+
- **Markdown レンダリング**(シンタックスハイライトとフレームワーク対応コンテンツ)
|
|
17
|
+
- **管理インターフェース**(翻訳の管理用)
|
|
18
|
+
- **CLI ツール**(翻訳ワークフローの自動化用)
|
|
19
|
+
|
|
20
|
+
## はじめに
|
|
21
|
+
|
|
22
|
+
[入門ガイド](/ja/getting-started)をご覧ください。docs-i18n のプロジェクトへの導入方法を学べます。
|
|
23
|
+
|
|
24
|
+
## 今後にご期待ください
|
|
25
|
+
|
|
26
|
+
今後のリリースでは、エキサイティングな新機能を予定しています。最新の情報はこのブログでお届けします!
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: "TanStack Query v5 正式发布"
|
|
3
|
+
published: "2024-10-01"
|
|
4
|
+
excerpt: "TanStack Query v5 带来了简化的 API、更好的 TypeScript 支持、改进的开发工具和更小的包体积。以下是你需要了解的一切。"
|
|
5
|
+
authors:
|
|
6
|
+
- "Tanner Linsley"
|
|
7
|
+
- "Dominik Dorfmeister"
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
我们非常高兴地宣布 TanStack Query v5 正式发布!这个版本凝聚了社区数月的努力,在各方面都带来了重大改进。
|
|
11
|
+
|
|
12
|
+
## 新特性
|
|
13
|
+
|
|
14
|
+
### 简化的 API
|
|
15
|
+
|
|
16
|
+
v5 最直观的变化是简化的 API。我们移除了多种函数签名重载,统一使用单一的对象语法:
|
|
17
|
+
|
|
18
|
+
```tsx
|
|
19
|
+
// v4 — 多种重载方式
|
|
20
|
+
useQuery(['todos'], fetchTodos)
|
|
21
|
+
useQuery(['todos'], fetchTodos, { staleTime: 5000 })
|
|
22
|
+
useQuery({ queryKey: ['todos'], queryFn: fetchTodos })
|
|
23
|
+
|
|
24
|
+
// v5 — 统一的对象语法
|
|
25
|
+
useQuery({
|
|
26
|
+
queryKey: ['todos'],
|
|
27
|
+
queryFn: fetchTodos,
|
|
28
|
+
staleTime: 5000,
|
|
29
|
+
})
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
这使得 API 更容易学习,并提供更好的 TypeScript 类型推断。
|
|
33
|
+
|
|
34
|
+
### 更好的 TypeScript 支持
|
|
35
|
+
|
|
36
|
+
v5 包含重大的 TypeScript 改进:
|
|
37
|
+
|
|
38
|
+
- **严格的查询键类型** — 查询键在整个流程中都经过严格类型检查
|
|
39
|
+
- **推断的返回类型** — `useQuery` 能从 `queryFn` 正确推断返回类型
|
|
40
|
+
- **类型安全的错误处理** — 通过新的 `Error` 泛型参数实现类型安全的错误处理
|
|
41
|
+
|
|
42
|
+
```tsx
|
|
43
|
+
const { data, error } = useQuery({
|
|
44
|
+
queryKey: ['user', userId],
|
|
45
|
+
queryFn: async () => {
|
|
46
|
+
const res = await fetch(`/api/users/${userId}`)
|
|
47
|
+
if (!res.ok) throw new ApiError(res.status, await res.text())
|
|
48
|
+
return res.json() as Promise<User>
|
|
49
|
+
},
|
|
50
|
+
})
|
|
51
|
+
|
|
52
|
+
// error 的类型为 ApiError | null
|
|
53
|
+
if (error) {
|
|
54
|
+
console.log(error.status) // TypeScript 知道这个属性存在
|
|
55
|
+
}
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
### 更小的包体积
|
|
59
|
+
|
|
60
|
+
通过 tree-shaking 优化和移除废弃的 API,我们将核心包体积减少了约 20%。
|
|
61
|
+
|
|
62
|
+
| 包 | v4 | v5 | 变化 |
|
|
63
|
+
|---|---|---|---|
|
|
64
|
+
| `@tanstack/react-query` | 12.4 KB | 9.8 KB | -21% |
|
|
65
|
+
| `@tanstack/query-core` | 10.1 KB | 8.2 KB | -19% |
|
|
66
|
+
|
|
67
|
+
## 破坏性变更
|
|
68
|
+
|
|
69
|
+
> [!WARNING]
|
|
70
|
+
> v5 包含多项破坏性变更。请在升级前仔细阅读完整的迁移指南。
|
|
71
|
+
|
|
72
|
+
主要破坏性变更:
|
|
73
|
+
|
|
74
|
+
1. **移除了重载签名** — 所有 hook 现在仅使用对象语法
|
|
75
|
+
2. **`cacheTime` 重命名为 `gcTime`** — 更好地反映其用途(垃圾回收时间)
|
|
76
|
+
3. **`status: 'loading'` 重命名为 `status: 'pending'`** — 与 Promise 术语保持一致
|
|
77
|
+
4. **最低 TypeScript 版本要求为 4.7**
|
|
78
|
+
|
|
79
|
+
## 迁移
|
|
80
|
+
|
|
81
|
+
我们提供了 codemod 工具来自动化大部分迁移工作:
|
|
82
|
+
|
|
83
|
+
```bash
|
|
84
|
+
npx @tanstack/query-codemod v5 ./src
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
立即开始使用 v5:
|
|
88
|
+
|
|
89
|
+
```bash
|
|
90
|
+
npm install @tanstack/react-query@latest
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
感谢所有让这个版本成为可能的 100 多位贡献者!
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: "你好世界:docs-i18n 博客上线"
|
|
3
|
+
published: "2024-01-15"
|
|
4
|
+
excerpt: "欢迎来到 docs-i18n 博客!我们将分享更新、教程和文档国际化的最佳实践。"
|
|
5
|
+
authors:
|
|
6
|
+
- "docs-i18n Team"
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
欢迎来到 docs-i18n 博客!这里我们将分享项目更新、教程和文档国际化的最佳实践。
|
|
10
|
+
|
|
11
|
+
## 什么是 docs-i18n?
|
|
12
|
+
|
|
13
|
+
docs-i18n 是一个通用的文档翻译引擎,可以轻松维护多语言文档站点。它提供:
|
|
14
|
+
|
|
15
|
+
- **基于文件系统的内容加载**,支持 i18n 回退
|
|
16
|
+
- **Markdown 渲染**,支持语法高亮和框架感知内容
|
|
17
|
+
- **管理界面**,用于管理翻译
|
|
18
|
+
- **CLI 工具**,用于自动化翻译工作流
|
|
19
|
+
|
|
20
|
+
## 开始使用
|
|
21
|
+
|
|
22
|
+
查看我们的[入门指南](/zh-hans/getting-started)来了解如何为你的项目设置 docs-i18n。
|
|
23
|
+
|
|
24
|
+
## 敬请期待
|
|
25
|
+
|
|
26
|
+
我们计划在即将发布的版本中推出令人兴奋的新功能。关注这个博客获取最新更新!
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
{
|
|
2
|
+
"sections": [
|
|
3
|
+
{
|
|
4
|
+
"label": "Getting Started",
|
|
5
|
+
"children": [
|
|
6
|
+
{ "label": "Introduction", "to": "getting-started" }
|
|
7
|
+
]
|
|
8
|
+
},
|
|
9
|
+
{
|
|
10
|
+
"label": "Usage",
|
|
11
|
+
"children": [
|
|
12
|
+
{ "label": "CLI Commands", "to": "cli" },
|
|
13
|
+
{ "label": "Configuration", "to": "configuration" },
|
|
14
|
+
{ "label": "Admin Dashboard", "to": "admin" }
|
|
15
|
+
]
|
|
16
|
+
},
|
|
17
|
+
{
|
|
18
|
+
"label": "Advanced",
|
|
19
|
+
"children": [
|
|
20
|
+
{ "label": "Architecture", "to": "architecture" },
|
|
21
|
+
{ "label": "Deployment", "to": "deployment" }
|
|
22
|
+
]
|
|
23
|
+
}
|
|
24
|
+
]
|
|
25
|
+
}
|