异常处理
分类 | Hooks | Classes |
---|---|---|
属性类型检查 | TypeScript | static propTypes v0.13/ES2022 |
错误边界 | react-error-boundary | static getDerivedStateFromError(error) v16.6 |
\- | - | componentDidCatch(error, info) v16.0 |
\- | - | onCaughtError() v19.0 |
\- | - | onUncaughtError() v19.0 |
\- | - | onRecoverableError() v19.0 |
严格模式 | <StrictMode> v16.3 | - |
大纲
- 异常处理
- 类型检查
- TypeScript
- static propTypes / .propTypes
- 错误边界
- react-error-boundary
- static getDerivedStateFromError(error)
- componentDidCatch(error, info)
- 严格模式
<StrictMode>
- 类型检查
- Hooks
- Classes