官术网_书友最值得收藏!

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>
...
主站蜘蛛池模板: 任丘市| 泰州市| 宣汉县| 辽源市| 石屏县| 拜泉县| 大新县| 若尔盖县| 大港区| 怀远县| 建始县| 华宁县| 清涧县| 墨江| 阿拉善盟| 民权县| 赤水市| 蓝山县| 桂林市| 抚顺县| 西乌珠穆沁旗| 台江县| 万载县| 开鲁县| 陵水| 德格县| 余江县| 化德县| 临潭县| 娱乐| 广东省| 石首市| 四平市| 若尔盖县| 通化市| 西充县| 正镶白旗| 巴青县| 石家庄市| 同心县| 丰县|