Nâng CaoReact iconReact

Error Boundaries hoạt động thế nào? Hạn chế gì?

Class component dùng componentDidCatchgetDerivedStateFromError bắt lỗi render.

  • Hiển thị fallback UI thay vì crash toàn app.
  • Hạn chế: không bắt lỗi trong event handlers, async code, SSR, và chính Error Boundary.
  • Dùng react-error-boundary library cho function components.

Xem toàn bộ React cùng filter theo level & chủ đề con.

Mở danh sách React