|
1 | 1 | --- |
2 | | -title: Debugging and Troubleshooting |
| 2 | +title: λλ²κΉ
λ° λ¬Έμ ν΄κ²° |
3 | 3 | --- |
4 | 4 |
|
5 | 5 | <Intro> |
6 | | -This guide helps you identify and fix issues when using React Compiler. Learn how to debug compilation problems and resolve common issues. |
| 6 | +μ΄ κ°μ΄λμμλ React μ»΄νμΌλ¬ μ¬μ© μ λ°μνλ λ¬Έμ λ₯Ό μλ³νκ³ ν΄κ²°νλ λ°©λ²μ μμλ΄
λλ€. μ»΄νμΌ λ¬Έμ λ₯Ό λλ²κΉ
νκ³ μΌλ°μ μΈ λ¬Έμ λ₯Ό ν΄κ²°νλ λ°©λ²μ λ°°μλλ€. |
7 | 7 | </Intro> |
8 | 8 |
|
9 | 9 | <YouWillLearn> |
10 | 10 |
|
11 | | -* The difference between compiler errors and runtime issues |
12 | | -* Common patterns that break compilation |
13 | | -* Step-by-step debugging workflow |
| 11 | +* μ»΄νμΌλ¬ μ€λ₯μ λ°νμ λ¬Έμ μ μ°¨μ΄ |
| 12 | +* μ»΄νμΌμ λ°©ν΄νλ μΌλ°μ μΈ ν¨ν΄ |
| 13 | +* λ¨κ³λ³ λλ²κΉ
μν¬νλ‘μ° |
14 | 14 |
|
15 | 15 | </YouWillLearn> |
16 | 16 |
|
17 | | -## Understanding Compiler Behavior {/*understanding-compiler-behavior*/} |
| 17 | +## μ»΄νμΌλ¬ λμ μ΄ν΄νκΈ° {/*understanding-compiler-behavior*/} |
18 | 18 |
|
19 | | -React Compiler is designed to handle code that follows the [Rules of React](/reference/rules). When it encounters code that might break these rules, it safely skips optimization rather than risk changing your app's behavior. |
| 19 | +React μ»΄νμΌλ¬λ [Reactμ κ·μΉ](/reference/rules)μ λ°λ₯΄λ μ½λλ₯Ό μ²λ¦¬νλλ‘ μ€κ³λμμ΅λλ€. μ΄λ¬ν κ·μΉμ μλ°ν μ μλ μ½λλ₯Ό λ§λλ©΄ μ±μ λμμ λ³κ²½νλ μνμ κ°μνκΈ°λ³΄λ€ μμ νκ² μ΅μ νλ₯Ό 건λλλλ€. |
20 | 20 |
|
21 | | -### Compiler Errors vs Runtime Issues {/*compiler-errors-vs-runtime-issues*/} |
| 21 | +### μ»΄νμΌλ¬ μ€λ₯ vs λ°νμ λ¬Έμ {/*compiler-errors-vs-runtime-issues*/} |
22 | 22 |
|
23 | | -**Compiler errors** occur at build time and prevent your code from compiling. These are rare because the compiler is designed to skip problematic code rather than fail. |
| 23 | +**μ»΄νμΌλ¬ μ€λ₯**λ λΉλ μμ μ λ°μνλ©° μ½λκ° μ»΄νμΌλμ§ μκ² ν©λλ€. μ»΄νμΌλ¬λ λ¬Έμ κ° μλ μ½λλ₯Ό μ€ν¨μν€κΈ°λ³΄λ€ 건λλ°λλ‘ μ€κ³λμ΄ μκΈ° λλ¬Έμ μ΄λ¬ν μ€λ₯λ λλ
λλ€. |
24 | 24 |
|
25 | | -**Runtime issues** occur when compiled code behaves differently than expected. Most of the time, if you encounter an issue with React Compiler, it's a runtime issue. This typically happens when your code violates the Rules of React in subtle ways that the compiler couldn't detect, and the compiler mistakenly compiled a component it should have skipped. |
| 25 | +**λ°νμ λ¬Έμ **λ μ»΄νμΌλ μ½λκ° μμκ³Ό λ€λ₯΄κ² λμν λ λ°μν©λλ€. React μ»΄νμΌλ¬ κ΄λ ¨ λ¬Έμ κ° λ°μνλ©΄ λλΆλΆ λ°νμ λ¬Έμ μ
λλ€. μ΄λ μΌλ°μ μΌλ‘ μ»΄νμΌλ¬κ° κ°μ§ν μ μλ λ―Έλ¬ν λ°©μμΌλ‘ μ½λκ° Reactμ κ·μΉμ μλ°νκ³ , μ»΄νμΌλ¬κ° 건λλ°μ΄μΌ νλ μ»΄ν¬λνΈλ₯Ό μ€μλ‘ μ»΄νμΌνμ λ λ°μν©λλ€. |
26 | 26 |
|
27 | | -When debugging runtime issues, focus your efforts on finding Rules of React violations in the affected components that were not detected by the ESLint rule. The compiler relies on your code following these rules, and when they're broken in ways it can't detect, that's when runtime problems occur. |
| 27 | +λ°νμ λ¬Έμ λ₯Ό λλ²κΉ
ν λλ ESLint κ·μΉμ΄ κ°μ§νμ§ λͺ»ν μν₯λ°λ μ»΄ν¬λνΈμ React κ·μΉ μλ°μ μ°Ύλ λ° μ§μ€νμΈμ. μ»΄νμΌλ¬λ μ½λκ° μ΄λ¬ν κ·μΉμ λ°λ₯Έλ€κ³ κ°μ νλ©°, κ°μ§ν μ μλ λ°©μμΌλ‘ κ·μΉμ΄ μλ°λλ©΄ λ°νμ λ¬Έμ κ° λ°μν©λλ€. |
28 | 28 |
|
29 | 29 |
|
30 | | -## Common Breaking Patterns {/*common-breaking-patterns*/} |
| 30 | +## μ»΄νμΌμ λ°©ν΄νλ μΌλ°μ μΈ ν¨ν΄ {/*common-breaking-patterns*/} |
31 | 31 |
|
32 | | -One of the main ways React Compiler can break your app is if your code was written to rely on memoization for correctness. This means your app depends on specific values being memoized to work properly. Since the compiler may memoize differently than your manual approach, this can lead to unexpected behavior like effects over-firing, infinite loops, or missing updates. |
| 32 | +React μ»΄νμΌλ¬κ° μ±μ λ§κ°λ¨λ¦΄ μ μλ μ£Όμ μμΈ μ€ νλλ μ½λκ° μ νμ±μ μν΄ λ©λͺ¨μ΄μ μ΄μ
μ μμ‘΄νλλ‘ μμ±λ κ²½μ°μ
λλ€. μ΄λ μ±μ΄ μ λλ‘ μλνκΈ° μν΄ νΉμ κ°μ΄ λ©λͺ¨μ΄μ μ΄μ
λλ κ²μ μμ‘΄νλ€λ μλ―Έμ
λλ€. μ»΄νμΌλ¬κ° μλ λ°©μκ³Ό λ€λ₯΄κ² λ©λͺ¨μ΄μ μ΄μ
ν μ μμΌλ―λ‘, Effectκ° κ³Όλνκ² μ€νλκ±°λ 무ν 루νκ° λ°μνκ±°λ μ
λ°μ΄νΈκ° λλ½λλ λ±μ μμμΉ λͺ»ν λμμ΄ λ°μν μ μμ΅λλ€. |
33 | 33 |
|
34 | | -Common scenarios where this occurs: |
| 34 | +μ΄λ° μν©μ΄ λ°μνλ μΌλ°μ μΈ μλ리μ€λ λ€μκ³Ό κ°μ΅λλ€. |
35 | 35 |
|
36 | | -- **Effects that rely on referential equality** - When effects depend on objects or arrays maintaining the same reference across renders |
37 | | -- **Dependency arrays that need stable references** - When unstable dependencies cause effects to fire too often or create infinite loops |
38 | | -- **Conditional logic based on reference checks** - When code uses referential equality checks for caching or optimization |
| 36 | +- **μ°Έμ‘° λλ±μ±μ μμ‘΄νλ Effect** - Effectκ° λ λλ§ κ°μ λμΌν μ°Έμ‘°λ₯Ό μ μ§νλ κ°μ²΄λ λ°°μ΄μ μμ‘΄νλ κ²½μ° |
| 37 | +- **μμ μ μΈ μ°Έμ‘°κ° νμν μμ‘΄μ± λ°°μ΄** - λΆμμ ν μμ‘΄μ±μ΄ Effectλ₯Ό λ무 μμ£Ό μ€ννκ±°λ 무ν 루νλ₯Ό μμ±νλ κ²½μ° |
| 38 | +- **μ°Έμ‘° κ²μ¬ κΈ°λ° μ‘°κ±΄λΆ λ‘μ§** - μ½λκ° μΊμ±μ΄λ μ΅μ νλ₯Ό μν΄ μ°Έμ‘° λλ±μ± κ²μ¬λ₯Ό μ¬μ©νλ κ²½μ° |
39 | 39 |
|
40 | | -## Debugging Workflow {/*debugging-workflow*/} |
| 40 | +## λλ²κΉ
μν¬νλ‘μ° {/*debugging-workflow*/} |
41 | 41 |
|
42 | | -Follow these steps when you encounter issues: |
| 42 | +λ¬Έμ κ° λ°μνλ©΄ λ€μ λ¨κ³λ₯Ό λ°λ₯΄μΈμ. |
43 | 43 |
|
44 | | -### Compiler Build Errors {/*compiler-build-errors*/} |
| 44 | +### μ»΄νμΌλ¬ λΉλ μ€λ₯ {/*compiler-build-errors*/} |
45 | 45 |
|
46 | | -If you encounter a compiler error that unexpectedly breaks your build, this is likely a bug in the compiler. Report it to the [facebook/react](https://github.com/facebook/react/issues) repository with: |
47 | | -- The error message |
48 | | -- The code that caused the error |
49 | | -- Your React and compiler versions |
| 46 | +λΉλλ₯Ό μμμΉ μκ² μ€λ¨μν€λ μ»΄νμΌλ¬ μ€λ₯κ° λ°μνλ©΄ μ»΄νμΌλ¬μ λ²κ·ΈμΌ κ°λ₯μ±μ΄ λμ΅λλ€. λ€μ μ 보μ ν¨κ» [facebook/react](https://github.com/facebook/react/issues) μ μ₯μμ λ³΄κ³ ν΄ μ£ΌμΈμ. |
| 47 | +- μ€λ₯ λ©μμ§ |
| 48 | +- μ€λ₯λ₯Ό λ°μμν¨ μ½λ |
| 49 | +- React λ° μ»΄νμΌλ¬ λ²μ |
50 | 50 |
|
51 | | -### Runtime Issues {/*runtime-issues*/} |
| 51 | +### λ°νμ λ¬Έμ {/*runtime-issues*/} |
52 | 52 |
|
53 | | -For runtime behavior issues: |
| 53 | +λ°νμ λμ λ¬Έμ μ κ²½μ° λ€μμ νμΈνμΈμ. |
54 | 54 |
|
55 | | -### 1. Temporarily Disable Compilation {/*temporarily-disable-compilation*/} |
| 55 | +### 1. μΌμμ μΌλ‘ μ»΄νμΌ λΉνμ±ν {/*temporarily-disable-compilation*/} |
56 | 56 |
|
57 | | -Use `"use no memo"` to isolate whether an issue is compiler-related: |
| 57 | +`"use no memo"`λ₯Ό μ¬μ©νμ¬ λ¬Έμ κ° μ»΄νμΌλ¬μ κ΄λ ¨μ΄ μλμ§ νμΈν©λλ€. |
58 | 58 |
|
59 | 59 | ```js |
60 | 60 | function ProblematicComponent() { |
61 | | - "use no memo"; // Skip compilation for this component |
62 | | - // ... rest of component |
| 61 | + "use no memo"; // μ΄ μ»΄ν¬λνΈμ μ»΄νμΌ κ±΄λλ°κΈ° |
| 62 | + // ... λλ¨Έμ§ μ»΄ν¬λνΈ |
63 | 63 | } |
64 | 64 | ``` |
65 | 65 |
|
66 | | -If the issue disappears, it's likely related to a Rules of React violation. |
| 66 | +λ¬Έμ κ° μ¬λΌμ§λ©΄ React κ·μΉ μλ°κ³Ό κ΄λ ¨μ΄ μμ κ°λ₯μ±μ΄ λμ΅λλ€. |
67 | 67 |
|
68 | | -You can also try removing manual memoization (useMemo, useCallback, memo) from the problematic component to verify that your app works correctly without any memoization. If the bug still occurs when all memoization is removed, you have a Rules of React violation that needs to be fixed. |
| 68 | +λ¬Έμ κ° μλ μ»΄ν¬λνΈμμ μλ λ©λͺ¨μ΄μ μ΄μ
(`useMemo`, `useCallback`, `memo`)μ μ κ±°νμ¬ λ©λͺ¨μ΄μ μ΄μ
μμ΄λ μ±μ΄ μ¬λ°λ₯΄κ² μλνλμ§ νμΈν΄ λ³Ό μλ μμ΅λλ€. λͺ¨λ λ©λͺ¨μ΄μ μ΄μ
μ μ κ±°ν΄λ λ²κ·Έκ° κ³μ λ°μνλ©΄ μμ ν΄μΌ ν React κ·μΉ μλ°μ΄ μλ κ²μ
λλ€. |
69 | 69 |
|
70 | | -### 2. Fix Issues Step by Step {/*fix-issues-step-by-step*/} |
| 70 | +### 2. λ¨κ³λ³λ‘ λ¬Έμ ν΄κ²° {/*fix-issues-step-by-step*/} |
71 | 71 |
|
72 | | -1. Identify the root cause (often memoization-for-correctness) |
73 | | -2. Test after each fix |
74 | | -3. Remove `"use no memo"` once fixed |
75 | | -4. Verify the component shows the β¨ badge in React DevTools |
| 72 | +1. κ·Όλ³Έ μμΈ μλ³ (μ£Όλ‘ μ νμ±μ μν λ©λͺ¨μ΄μ μ΄μ
) |
| 73 | +2. κ° μμ ν ν
μ€νΈ |
| 74 | +3. μμ μλ£ ν `"use no memo"` μ κ±° |
| 75 | +4. React DevToolsμμ μ»΄ν¬λνΈμ β¨ λ°°μ§κ° νμλλμ§ νμΈ |
76 | 76 |
|
77 | | -## Reporting Compiler Bugs {/*reporting-compiler-bugs*/} |
| 77 | +## μ»΄νμΌλ¬ λ²κ·Έ λ³΄κ³ {/*reporting-compiler-bugs*/} |
78 | 78 |
|
79 | | -If you believe you've found a compiler bug: |
| 79 | +μ»΄νμΌλ¬ λ²κ·Έλ₯Ό λ°κ²¬νλ€κ³ μκ°λλ©΄ λ€μμ νμΈνμΈμ. |
80 | 80 |
|
81 | | -1. **Verify it's not a Rules of React violation** - Check with ESLint |
82 | | -2. **Create a minimal reproduction** - Isolate the issue in a small example |
83 | | -3. **Test without the compiler** - Confirm the issue only occurs with compilation |
84 | | -4. **File an [issue](https://github.com/facebook/react/issues/new?template=compiler_bug_report.yml)**: |
85 | | - - React and compiler versions |
86 | | - - Minimal reproduction code |
87 | | - - Expected vs actual behavior |
88 | | - - Any error messages |
| 81 | +1. **React κ·μΉ μλ°μ΄ μλμ§ νμΈ** - ESLintλ‘ κ²μ¬ |
| 82 | +2. **μ΅μ μ¬ν μ¬λ‘ μμ±** - μμ μμλ‘ λ¬Έμ 격리 |
| 83 | +3. **μ»΄νμΌλ¬ μμ΄ ν
μ€νΈ** - μ»΄νμΌ μμλ§ λ¬Έμ κ° λ°μνλμ§ νμΈ |
| 84 | +4. **[μ΄μ](https://github.com/facebook/react/issues/new?template=compiler_bug_report.yml) λ±λ‘**: |
| 85 | + - React λ° μ»΄νμΌλ¬ λ²μ |
| 86 | + - μ΅μ μ¬ν μ½λ |
| 87 | + - μμ λμ vs μ€μ λμ |
| 88 | + - μ€λ₯ λ©μμ§ |
89 | 89 |
|
90 | | -## Next Steps {/*next-steps*/} |
| 90 | +## λ€μ λ¨κ³ {/*next-steps*/} |
91 | 91 |
|
92 | | -- Review the [Rules of React](/reference/rules) to prevent issues |
93 | | -- Check the [incremental adoption guide](/learn/react-compiler/incremental-adoption) for gradual rollout strategies |
| 92 | +- λ¬Έμ μλ°©μ μν΄ [Reactμ κ·μΉ](/reference/rules) κ²ν |
| 93 | +- μ μ§μ λ°°ν¬ μ λ΅μ μν [μ μ§μ λμ
κ°μ΄λ](/learn/react-compiler/incremental-adoption) νμΈ |
0 commit comments