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

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>
...
主站蜘蛛池模板: 鄂伦春自治旗| 保靖县| 邹城市| 望都县| 定南县| 宣威市| 阿拉善右旗| 西畴县| 扶余县| 霍邱县| 揭东县| 肥西县| 张家口市| 将乐县| 凌海市| 井研县| 文登市| 石楼县| 长治市| 城口县| 疏勒县| 漠河县| 邵阳市| 潞西市| 繁峙县| 小金县| 都昌县| 家居| 乌什县| 莱州市| 峨眉山市| 达拉特旗| 海宁市| 西峡县| 永胜县| 苏尼特右旗| 阜平县| 周口市| 万载县| 柘城县| 茌平县|