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

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>
...
主站蜘蛛池模板: 孟州市| 铅山县| 和林格尔县| 和林格尔县| 涞源县| 南投县| 盈江县| 金门县| 怀来县| 普安县| 胶南市| 镇宁| 双峰县| 建宁县| 七台河市| 文山县| 永顺县| 建昌县| 德庆县| 兰坪| 青州市| 拉孜县| 宿迁市| 奉节县| 高碑店市| 卢氏县| 大安市| 县级市| 故城县| 桐乡市| 阳信县| 连州市| 正镶白旗| 石城县| 石台县| 临安市| 莱西市| 徐州市| 苏尼特右旗| 江阴市| 屯留县|