๐Ÿ“šย Reference


๐Ÿ“œย Chapter


โ€ฃ

componentDidCatch(error, info)


componentDidCatch(error, info) {
  console.error("์—๋Ÿฌ ๋ฐœ์ƒ:", error);
  console.log("์—๋Ÿฌ ์œ„์น˜:", info.componentStack);
  sendErrorToSentry(error, info);
}

componentDidCatch, getDerivedStateFromError - ๋น„๊ต


๋ฉ”์„œ๋“œ ์‹œ์  ์—ญํ•  ์ฃผ์˜์‚ฌํ•ญ
componentDidCatch ์ปค๋ฐ‹ ๋‹จ๊ณ„ ์—๋Ÿฌ ๋กœ๊ทธ ์ˆ˜์ง‘, ๋ณต๊ตฌ ์ฒ˜๋ฆฌ side-effect ๊ฐ€๋Šฅ
getDerivedStateFromError ๋ Œ๋”๋ง ๋‹จ๊ณ„ ์—๋Ÿฌ ๊ฐ์ง€ โ†’ state ๋ณ€๊ฒฝ์œผ๋กœ fallback UI ๋ Œ๋” ๋น„๋™๊ธฐ/side-effect ๊ธˆ์ง€