use-error-boundary-hook
A React hook that allows you to use an error boundary in functional components.
Install
npm i use-errour-boundary-hook
Example
; { const Try Catch = ; return <Try> This is my content </Try> <Catch> Fallback content! </Catch> ;}
The hook returns more than just the Try
and Catch
component:
const Try Catch hasError error errorInfo = ;
Property | Type | |
---|---|---|
hasError |
Boolean | true if an error has been caught |
error | ErrorObject or null |
See React Docs |
errorInfo | Object or null |
See React Docs |