react-resilent
A high order component for resilently render components that might fail. It wraps them around a React Fiber error boundary.
- Tries to render your component
- Returns
<FallbackComponent />
after the maximum number of retries (props.maxRetries
)
⚠️ DISCLAIMER: Experimental
This ONLY works with react@next
(Fiber).
Demo
const Broken = { throw 'Broken!'} const ResilentComponent = Broken Component { console } { return <ResilentComponent maxRetries=2 onError=thisonError /> }
API
const MyResilentComponent = ReactComponent <MyResilentComponent maxRetries=number onError=func/>
opts.FallbackComponent
React component displayed after the maxRetries
props.maxRetries
(optional, defaults to 0)
Number of retries before showing the FallbackComponent
props.onError
(optional)
Callback for when errors are thrown