Skip to content

Commit aa4bf08

Browse files
fix: resolved conflicts
1 parent 37f727f commit aa4bf08

22 files changed

+25
-443
lines changed

src/content/learn/escape-hatches.md

Lines changed: 3 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -312,17 +312,7 @@ React 提供一個 linter 規則,可以驗證你是否已經正確地指定 Ef
312312

313313
## 從 Effect 分離事件 {/*separating-events-from-effects*/}
314314

315-
<<<<<<< HEAD
316-
<Wip>
317-
318-
這個章節會介紹一個 **實驗性 API,它還沒有被發布** 在 React 的正式版本。
319-
320-
</Wip>
321-
322-
Event handler 只在你做了相同的互動時才重新執行。與 event handler 不同,假設 Effect 讀取的任何值,像是 prop 或 state,與上一次 render 的不一樣, Effect 就會重新執行同步。有些時候,你想要混合兩種行為:Effect 的重新執行只對某些值反應,而其他的值不會。
323-
=======
324-
Event handlers only re-run when you perform the same interaction again. Unlike event handlers, Effects re-synchronize if any of the values they read, like props or state, are different than during last render. Sometimes, you want a mix of both behaviors: an Effect that re-runs in response to some values but not others.
325-
>>>>>>> 11cb6b591571caf5fa2a192117b6a6445c3f2027
315+
Event handler 只在你再次執行相同的互動時重新執行。與 event handler 不同,如果 Effect 讀取的任何值(例如 props 或 state)與上次渲染時的值不同,則 Effect 會重新同步。有時候,你需要混合使用這兩種行為:即 Effect 會回應某些值而重新執行,而其他值則不會重新執行。
326316

327317
所有在 Effect 中的程式碼都是 *反應性* 的。假如某些它讀取的反應性的值,在 re-render 時發生變化,它就會再執行一次。例如:假如 `roomId``theme` 之一已經改變,那麼這個 Effect 將會重新連接到聊天室。
328318

@@ -392,7 +382,7 @@ export default function App() {
392382
<hr />
393383
<ChatRoom
394384
roomId={roomId}
395-
theme={isDark ? 'dark' : 'light'}
385+
theme={isDark ? 'dark' : 'light'}
396386
/>
397387
</>
398388
);
@@ -459,13 +449,8 @@ label { display: block; margin-top: 10px; }
459449
```json package.json hidden
460450
{
461451
"dependencies": {
462-
<<<<<<< HEAD
463-
"react": "canary",
464-
"react-dom": "canary",
465-
=======
466452
"react": "latest",
467453
"react-dom": "latest",
468-
>>>>>>> 11cb6b591571caf5fa2a192117b6a6445c3f2027
469454
"react-scripts": "latest",
470455
"toastify-js": "1.12.0"
471456
},
@@ -530,7 +515,7 @@ export default function App() {
530515
<hr />
531516
<ChatRoom
532517
roomId={roomId}
533-
theme={isDark ? 'dark' : 'light'}
518+
theme={isDark ? 'dark' : 'light'}
534519
/>
535520
</>
536521
);

src/content/learn/removing-effect-dependencies.md

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -411,7 +411,7 @@ function Form() {
411411

412412
function handleSubmit() {
413413
setSubmitted(true);
414-
}
414+
}
415415

416416
// ...
417417
}
@@ -429,7 +429,7 @@ function Form() {
429429
// ✅ Good: Event-specific logic is called from event handlers
430430
post('/api/register');
431431
showNotification('Successfully registered!', theme);
432-
}
432+
}
433433

434434
// ...
435435
}
@@ -612,7 +612,7 @@ function ChatRoom({ roomId }) {
612612
<<<<<<< HEAD
613613
<Canary>
614614
615-
**The `useEffectEvent` API is currently only available in React’s Canary and Experimental channels.**
615+
**The `useEffectEvent` API is currently only available in React’s Canary and Experimental channels.**
616616
617617
[Learn more about React’s release channels here.](/community/versioning-policy#all-release-channels)
618618
@@ -889,7 +889,7 @@ const options2 = { serverUrl: 'https://localhost:1234', roomId: 'music' };
889889
console.log(Object.is(options1, options2)); // false
890890
```
891891
892-
**Object and function dependencies can make your Effect re-synchronize more often than you need.**
892+
**Object and function dependencies can make your Effect re-synchronize more often than you need.**
893893
894894
This is why, whenever possible, you should try to avoid objects and functions as your Effect's dependencies. Instead, try moving them outside the component, inside the Effect, or extracting primitive values out of them.
895895
@@ -1836,13 +1836,8 @@ Another of these functions only exists to pass some state to an imported API met
18361836
```json package.json hidden
18371837
{
18381838
"dependencies": {
1839-
<<<<<<< HEAD
1840-
"react": "canary",
1841-
"react-dom": "canary",
1842-
=======
18431839
"react": "latest",
18441840
"react-dom": "latest",
1845-
>>>>>>> 11cb6b591571caf5fa2a192117b6a6445c3f2027
18461841
"react-scripts": "latest",
18471842
"toastify-js": "1.12.0"
18481843
},
@@ -2136,13 +2131,8 @@ As a result, the chat re-connects only when something meaningful (`roomId` or `i
21362131
```json package.json hidden
21372132
{
21382133
"dependencies": {
2139-
<<<<<<< HEAD
2140-
"react": "canary",
2141-
"react-dom": "canary",
2142-
=======
21432134
"react": "latest",
21442135
"react-dom": "latest",
2145-
>>>>>>> 11cb6b591571caf5fa2a192117b6a6445c3f2027
21462136
"react-scripts": "latest",
21472137
"toastify-js": "1.12.0"
21482138
},

src/content/learn/reusing-logic-with-custom-hooks.md

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -840,7 +840,7 @@ Every time your `ChatRoom` component re-renders, it passes the latest `roomId` a
840840
<<<<<<< HEAD
841841
<Canary>
842842
843-
**The `useEffectEvent` API is currently only available in React’s Canary and Experimental channels.**
843+
**The `useEffectEvent` API is currently only available in React’s Canary and Experimental channels.**
844844
845845
[Learn more about React’s release channels here.](/community/versioning-policy#all-release-channels)
846846
@@ -1075,13 +1075,8 @@ export function showNotification(message, theme = 'dark') {
10751075
```json package.json hidden
10761076
{
10771077
"dependencies": {
1078-
<<<<<<< HEAD
1079-
"react": "canary",
1080-
"react-dom": "canary",
1081-
=======
10821078
"react": "latest",
10831079
"react-dom": "latest",
1084-
>>>>>>> 11cb6b591571caf5fa2a192117b6a6445c3f2027
10851080
"react-scripts": "latest",
10861081
"toastify-js": "1.12.0"
10871082
},

0 commit comments

Comments
 (0)