Skip to content

Commit 5f0142a

Browse files
authored
docs: add comment translate in useSyncExternalStore.md (#1844)
2 parents 7246ce8 + 1e10ad7 commit 5f0142a

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

src/content/reference/react/useSyncExternalStore.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -69,10 +69,10 @@ function TodosApp() {
6969
function ShoppingApp() {
7070
const selectedProductId = useSyncExternalStore(...);
7171

72-
//Calling `use` with a Promise dependent on `selectedProductId`
72+
//使用依赖于 `selectedProductId` 的 Promise 调用 `use`
7373
const data = use(fetchItem(selectedProductId))
7474

75-
//Conditionally rendering a lazy component based on `selectedProductId`
75+
//根据 `selectedProductId` 有条件地渲染懒组件
7676
return selectedProductId != null ? <LazyProductDetailPage /> : <FeaturedProducts />;
7777
}
7878
```
@@ -119,7 +119,7 @@ export default function TodosApp() {
119119
const todos = useSyncExternalStore(todosStore.subscribe, todosStore.getSnapshot);
120120
return (
121121
<>
122-
<button onClick={() => todosStore.addTodo()}>Add todo</button>
122+
<button onClick={() => todosStore.addTodo()}>增加 todo</button>
123123
<hr />
124124
<ul>
125125
{todos.map(todo => (
@@ -220,7 +220,7 @@ import { useSyncExternalStore } from 'react';
220220

221221
export default function ChatIndicator() {
222222
const isOnline = useSyncExternalStore(subscribe, getSnapshot);
223-
return <h1>{isOnline ? 'Online' : 'Disconnected'}</h1>;
223+
return <h1>{isOnline ? '在线' : '离线'}</h1>;
224224
}
225225

226226
function getSnapshot() {
@@ -273,19 +273,19 @@ import { useOnlineStatus } from './useOnlineStatus.js';
273273

274274
function StatusBar() {
275275
const isOnline = useOnlineStatus();
276-
return <h1>{isOnline ? 'Online' : 'Disconnected'}</h1>;
276+
return <h1>{isOnline ? '在线' : '离线'}</h1>;
277277
}
278278

279279
function SaveButton() {
280280
const isOnline = useOnlineStatus();
281281

282282
function handleSaveClick() {
283-
console.log('Progress saved');
283+
console.log('保存的进度');
284284
}
285285

286286
return (
287287
<button disabled={!isOnline} onClick={handleSaveClick}>
288-
{isOnline ? 'Save progress' : 'Reconnecting...'}
288+
{isOnline ? '保存的进度' : '重新连接...'}
289289
</button>
290290
);
291291
}

0 commit comments

Comments
 (0)