Feature: Add native support for error boundaries in Functional Components via a new hook
Issue Body (Example): 💡 Problem: Currently, to implement an Error Boundary in a React application (a component that catches JavaScript errors anywhere in its child component tree, logs those errors, and displays a fallback UI), developers must use a Class Component with the componentDidCatch lifecycle method. This breaks the pattern of using hooks/functional components for the rest of the application.
🚀 Proposed Feature: Introduce a new hook, perhaps useErrorBoundary, that allows a Functional Component to act as an Error Boundary.
Hi @Lokesh9106, thanks for the suggestion!
However, this issue is filed against the wrong repository. This repo (reactjs/react.dev) is for the React documentation website, not for React itself.
Feature requests for React core should be submitted to the main repository: https://github.com/facebook/react
That said, this is a well-known limitation that has been discussed extensively by the React team. The architectural challenge is that error boundaries need to catch errors during rendering (synchronously), while hooks run after render—making this difficult to implement.
In the meantime, you can use the react-error-boundary library, which provides a functional-component-friendly API (wrapping a class component internally). It was created by a former React team member and is widely used.
Closing as this is not a documentation issue.