* React์ ํ๋ก๋์
๊ณผ ๊ฐ๋ฐ ๋น๋๋ `componentDidCatch`๊ฐ ์๋ฌ๋ฅผ ์ฒ๋ฆฌํ๋ ๋ฐฉ์์ด ์ฝ๊ฐ ๋ค๋ฆ
๋๋ค. ๊ฐ๋ฐ์์๋, ์๋ฌ๋ `window`๊น์ง ๋ฒ๋ธ๋ง๋ ๊ฒ์ด๋ฉฐ, ์ด๋ `window.onerror` ๋๋ `window.addEventListener('error', callback)`๊ฐ `componentDidCatch`์ ์ํด ํ์ง๋ ์๋ฌ๋ฅผ ๊ฐ๋ก์ฑ๋ค๋ ๊ฒ์ ์๋ฏธํฉ๋๋ค. ๋์ ํ๋ก๋์
์์, ์๋ฌ๋ ๋ฒ๋ธ๋ง๋์ง ์์ ๊ฒ์ด๋ฉฐ, ์ด๋ ์ด๋ค ์์์ ์๋ฌ ํธ๋ค๋ฌ๊ฐ `componentDidCatch`์ ์ํด ๋ช
์์ ์ผ๋ก ํ์ง๋์ง ์์ ์๋ฌ๋ง์ ์์ ํ๋ ๊ฒ์ ์๋ฏธํฉ๋๋ค.
0 commit comments