react-svg
react-svg copied to clipboard
Add Error Handler to Limit Exception Bubbling
The idea is to limit the scope in which exceptions in the injection code can break the react component. This reduces the risk of total app failure.
Added onError
handler because passing new errors into afterInjection
felt like I was overloading the function.
Example:
Before this would break your application, after the error is routed into onError
and then defaulted to the fallback.
<ReactSVG
beforeInjection={() => {
throw new Error('test error')
}}
fallback={fallback}
src={`http://localhost/${uuid}.svg`}
/>
@tanem
Thanks for this PR @ProjectBarks. Sorry for the long delay, things got away on me a bit late last year 😅
Will have a look through the changes and will get back to you. Will bring the branch up-to-date etc, so there'll be some forced pushes ⚠️
Modified a few things and will merge now. Thanks for your contribution 🎉
Released in v16.0.0
.