What are error boundaries in ReactJS?

The concept of error boundaries was introduced in the version 16 of React, they provide a way for us to catch errors that occur in the render phase. Any component which uses one of the following lifecycle methods, is considered an error boundary.
An error boundary can detect an error in the following phases:

  • Render phase
  • Inside a lifecycle method
  • Inside the constructor