Skip to content

Commit 44da919

Browse files
nh0627hg-pyun
andauthored
Update reference-react-component.md (#280)
* Update reference-react-component.md * Update content/docs/reference-react-component.md Co-authored-by: Haegul Pyun <[email protected]> * Update content/docs/reference-react-component.md Co-authored-by: Haegul Pyun <[email protected]> * Update content/docs/reference-react-component.md Co-authored-by: Haegul Pyun <[email protected]> Co-authored-by: Haegul Pyun <[email protected]>
1 parent 99d7070 commit 44da919

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

content/docs/reference-react-component.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -406,9 +406,15 @@ class ErrorBoundary extends React.Component {
406406
}
407407
```
408408

409+
리액트의 `componentDidCatch()`가 오류를 처리하는 방식은 프로덕션과 개발 빌드가 약간 다릅니다.
410+
411+
개발 빌드에서, 오류는 `window`까지 전파됩니다. 이는 `window.onerror``window.addEventListener('error', callback)``componentDidCatch()`에서 잡은 오류를 인터셉트하는 것을 의미합니다.
412+
413+
그러나 프로덕션 빌드에서 오류는 전파되지 않습니다. 즉 상위 오류 핸들러는 `componentDidCatch()`에 의해 명시적으로 잡히지 않은 오류만 받습니다.
414+
409415
> 주의
410416
>
411-
> 오류 이벤트 내에서는 `setState()`의 호출을 통하여 `componentDidCatch()`로 구현된 대체 UI를 렌더링할 수 있습니다. 하지만 이런 방식은 나중 릴리즈에서는 사용할 수 없게 것입니다.
417+
> 오류 이벤트 내에서는 `setState()`의 호출을 통하여 `componentDidCatch()`로 구현된 대체 UI를 렌더링할 수 있습니다. 하지만 이런 방식은 이후의 릴리즈에서는 사용할 수 없게 것입니다.
412418
> 대체 UI 렌더링 제어를 하려면 `static getDerivedStateFromError()`를 대신 사용하세요.
413419
414420
* * *

0 commit comments

Comments
 (0)