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

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>
...
主站蜘蛛池模板: 黄龙县| 林芝县| 健康| 平凉市| 通河县| 兴安盟| 高雄市| 大理市| 漳浦县| 化德县| 九龙坡区| 平潭县| 连山| 隆德县| 江油市| 伽师县| 昭觉县| 卢龙县| 长沙市| 苗栗市| 永丰县| 镇远县| 萝北县| 田阳县| 新疆| 宝坻区| 宝应县| 义马市| 大兴区| 林州市| 北票市| 闽侯县| 如皋市| 青岛市| 南澳县| 琼结县| 堆龙德庆县| 罗城| 定兴县| 新民市| 斗六市|