- 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>
...
推薦閱讀
- 數(shù)據(jù)庫系統(tǒng)原理及MySQL應(yīng)用教程(第2版)
- Mastering AWS Lambda
- 國際大學(xué)生程序設(shè)計(jì)競賽中山大學(xué)內(nèi)部選拔真題解(二)
- Mastering phpMyAdmin 3.4 for Effective MySQL Management
- Java EE框架整合開發(fā)入門到實(shí)戰(zhàn):Spring+Spring MVC+MyBatis(微課版)
- C/C++常用算法手冊(cè)(第3版)
- aelf區(qū)塊鏈應(yīng)用架構(gòu)指南
- JS全書:JavaScript Web前端開發(fā)指南
- Android Native Development Kit Cookbook
- RabbitMQ Cookbook
- MySQL從入門到精通(軟件開發(fā)視頻大講堂)
- PHP編程基礎(chǔ)與實(shí)例教程
- CRYENGINE Game Development Blueprints
- Go語言從入門到精通
- Machine Learning for OpenCV