- Hands-On Design Patterns with React Native
- Mateusz Grzesiukiewicz
- 101字
- 2021-08-13 15:13:01
Understanding error boundaries
Error boundaries can be placed in many different fashions, and each approach has its own benefits. Choose one that fits your use case. For ideas, skip to the next section. Here, we will demonstrate how the app behaves, depending on the placement of the error boundaries.
This first example uses two error boundaries around the LikeCounter component. If one of the LikeCounter components crashes, the other one will still be shown:
...
<AppErrorBoundary>
<LikeCounter />
</AppErrorBoundary>
<AppErrorBoundary>
<LikeCounter />
</AppErrorBoundary>
...
This second example uses one ErrorBoundary around two LikeCounter components. If one crashes, the other one will also be replaced by ErrorBoundary:
...
<AppErrorBoundary>
<LikeCounter />
<LikeCounter />
</AppErrorBoundary>
...
推薦閱讀
- Visual C++程序設計學習筆記
- 造個小程序:與微信一起干件正經事兒
- Mastering Ember.js
- Selenium Design Patterns and Best Practices
- Mastering Ubuntu Server
- Learning Selenium Testing Tools(Third Edition)
- Python編程從0到1(視頻教學版)
- jQuery Mobile移動應用開發實戰(第3版)
- Mastering ROS for Robotics Programming
- Serverless computing in Azure with .NET
- Python語言實用教程
- 分布式數據庫原理、架構與實踐
- Android技術內幕(系統卷)
- Hadoop Blueprints
- Learning Redux