DZone

Not long ago, React announced the release of version 16 with long-standing feature requests including error boundaries, fragments, improved server-side rendering, and more. Error boundaries are especially useful so that an error in one small part of the UI doesn’t break your entire application. Instead, it’s better to contain those errors to the affected components and recover gracefully.

You can try using error boundaries yourself in our working Codepen example. We forked it from Facebook’s initial version to show how to add Rollbar’s JavaScript error logging. When you open this page, you can activate an error boundary by clicking at least five times on the counter. You will then see the error message “Something went wrong.” Let’s dive deeper into this example to learn how error boundaries work.

Source: DZone