boundary@2.0.0
Provides boundary functions, (upper-bound and lower-bound).
BSD-2-Clause
2023-01-07
安装 (2.0.0)
npm install boundary@2.0.0
yarn add boundary@2.0.0
pnpm add boundary@2.0.0
bun add boundary@2.0.0
devDependencies (6)
| 包名 | 版本要求 |
|---|---|
| @types/mocha | ^10.0.1 |
| @types/node | ^18.11.18 |
| mocha | ^10.2.0 |
| ts-node | ^10.9.1 |
| ts-node-test-register | ^10.0.0 |
| typescript | ^4.9.4 |
相关教程
React 中错误边界无法捕获异步错误
Error Boundary 只捕获渲染生命周期中的错误不捕获 setTimeout、Promise.then 和事件处理中的错误。需要加 try/catch 手动处理。
React 中 componentDidCatch 捕获错误日志
componentDidCatch(error, info) 在 Error Boundary 中捕获渲染错误并记录错误信息和组件栈。配合日志上报系统可以在线上环境追踪前端错误。
React 错误边界 Error Boundaries 捕获渲染时的错误
React 组件渲染过程中抛出的错误如果不捕获整个应用会白屏。Error Boundary 可以捕获子组件的渲染错误并展示降级 UI。class 组件的 componentDidCatch 或第三方库 react-error-boundary 都可以实现。本文给出两种方式的示例代码。