Skip to content

Commit ca9ece2

Browse files
author
Dong uk Kim
authored
Fix missing translate (#1107)
* Fix missing translate * Fix missing translate
1 parent e7e1157 commit ca9ece2

1 file changed

Lines changed: 7 additions & 7 deletions

File tree

β€Žsrc/content/learn/synchronizing-with-effects.mdβ€Ž

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -600,28 +600,28 @@ ReactλŠ” λ§ˆμ§€λ§‰ μ˜ˆμ‹œμ™€ 같은 버그λ₯Ό μ°ΎκΈ° μœ„ν•΄ 개발 쀑에 컴포
600600
601601
<Pitfall>
602602
603-
#### Don't use refs to prevent Effects from firing {/*dont-use-refs-to-prevent-effects-from-firing*/}
603+
#### Effectκ°€ 두 번 μ‹€ν–‰λ˜λŠ” 것을 λ§‰κΈ°μœ„ν•΄ refλ₯Ό μ‚¬μš©ν•˜μ§€ λ§ˆμ„Έμš” {/*dont-use-refs-to-prevent-effects-from-firing*/}
604604
605-
A common pitfall for preventing Effects firing twice in development is to use a `ref` to prevent the Effect from running more than once. For example, you could "fix" the above bug with a `useRef`:
605+
Effectκ°€ 개발 λͺ¨λ“œμ—μ„œ 두 번 μ‹€ν–‰λ˜λŠ” 것을 λ§‰μœΌλ €λ‹€ ν”νžˆ λΉ μ§€λŠ” 함정은 `ref`λ₯Ό μ‚¬μš©ν•΄ Effectκ°€ ν•œ 번만 μ‹€ν–‰λ˜λ„λ‘ ν•˜λŠ” κ²ƒμž…λ‹ˆλ‹€. 예λ₯Ό λ“€μ–΄ μœ„μ˜ 버그λ₯Ό `useRef`λ₯Ό μ‚¬μš©ν•˜μ—¬ "μˆ˜μ •"ν•˜λ €κ³  ν•  μˆ˜λ„ μžˆμŠ΅λ‹ˆλ‹€:
606606
607607
```js {1,3-4}
608608
const connectionRef = useRef(null);
609609
useEffect(() => {
610-
// 🚩 This wont fix the bug!!!
610+
// 🚩 버그λ₯Ό μˆ˜μ •ν•˜μ§€ μ•ŠμŠ΅λ‹ˆλ‹€!!!
611611
if (!connectionRef.current) {
612612
connectionRef.current = createConnection();
613613
connectionRef.current.connect();
614614
}
615615
}, []);
616616
```
617617
618-
This makes it so you only see `"βœ… Connecting..."` once in development, but it doesn't fix the bug.
618+
μ΄λ ‡κ²Œ ν•˜λ©΄ 개발 λͺ¨λ“œμ—μ„œ `"βœ… μ—°κ²° 쀑..."`이 ν•œ 번만 λ³΄μ΄μ§€λ§Œ 버그가 μˆ˜μ •λœ 건 μ•„λ‹™λ‹ˆλ‹€.
619619
620-
When the user navigates away, the connection still isn't closed and when they navigate back, a new connection is created. As the user navigates across the app, the connections would keep piling up, the same as it would before the "fix".
620+
μ‚¬μš©μžκ°€ λ‹€λ₯Έ 곳에 가더라도 연결이 λŠμ–΄μ§€μ§€ μ•Šκ³  μ‚¬μš©μžκ°€ λ‹€μ‹œ λŒμ•„μ™”μ„ λ•Œ μƒˆλ‘œμš΄ 연결이 μƒμ„±λ©λ‹ˆλ‹€. μ‚¬μš©μžκ°€ 앱을 νƒμƒ‰ν•˜λ©΄ 버그가 μˆ˜μ •λ˜κΈ° μ „μ²˜λŸΌ 연결이 계속 μŒ“μ΄κ²Œ λ©λ‹ˆλ‹€.
621621
622-
To fix the bug, it is not enough to just make the Effect run once. The effect needs to work after re-mounting, which means the connection needs to be cleaned up like in the solution above.
622+
버그λ₯Ό μˆ˜μ •ν•˜κΈ° μœ„ν•΄μ„  Effectλ₯Ό λ‹¨μˆœνžˆ ν•œ 번만 μ‹€ν–‰λ˜λ„λ‘ λ§Œλ“œλŠ” κ²ƒμœΌλ‘œλŠ” λΆ€μ‘±ν•©λ‹ˆλ‹€. EffectλŠ” μœ„μ— μžˆλŠ” μ˜ˆμ‹œκ°€ 연결을 클린업 ν•œκ²ƒμ²˜λŸΌ λ‹€μ‹œ 마운트된 이후에도 μ œλŒ€λ‘œ λ™μž‘ν•΄μ•Ό ν•©λ‹ˆλ‹€.
623623
624-
See the examples below for how to handle common patterns.
624+
μ•„λž˜μ— μžˆλŠ” 일반적인 νŒ¨ν„΄μ„ λ‹€λ£¨λŠ” μ˜ˆμ‹œλ₯Ό μ‚΄νŽ΄λ³΄μ„Έμš”.
625625
626626
</Pitfall>
627627

0 commit comments

Comments
Β (0)