- 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>
...
推薦閱讀
- Boost.Asio C++ Network Programming(Second Edition)
- Functional Python Programming
- jQuery Mobile Web Development Essentials(Third Edition)
- 數(shù)字媒體應(yīng)用教程
- Python數(shù)據(jù)分析入門(mén)與實(shí)戰(zhàn)
- CMDB分步構(gòu)建指南
- 兩周自制腳本語(yǔ)言
- Apache Hive Essentials
- Learning Laravel 4 Application Development
- Building a Recommendation Engine with Scala
- Python編程與幾何圖形
- 計(jì)算機(jī)應(yīng)用基礎(chǔ)實(shí)踐教程
- Java程序員面試筆試寶典(第2版)
- Mudbox 2013 Cookbook
- Ext JS 4 Plugin and Extension Development