- 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>
...
推薦閱讀
- INSTANT Mock Testing with PowerMock
- 嵌入式軟件系統測試:基于形式化方法的自動化測試解決方案
- Python自然語言處理實戰:核心技術與算法
- Python Game Programming By Example
- 小程序開發原理與實戰
- Salesforce Reporting and Dashboards
- Create React App 2 Quick Start Guide
- Learning jQuery(Fourth Edition)
- 動手學數據結構與算法
- Kubernetes源碼剖析
- Troubleshooting Citrix XenApp?
- Mobile Forensics:Advanced Investigative Strategies
- Web前端測試與集成:Jasmine/Selenium/Protractor/Jenkins的最佳實踐
- Developing Java Applications with Spring and Spring Boot
- 現代JavaScript編程:經典范例與實踐技巧