-
-
Notifications
You must be signed in to change notification settings - Fork 180
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add onError
callback to useAsset
#504
Conversation
@thejustinwalsh, I'd love feedback from you on the solution here. |
My initial thoughts are that if you throw to the suspense boundary and use the callback for error handling, you won't be able to stop the hook from executing again. Would you? I was curious if we need a pattern that is more like reactQuery where you have two hooks... const { isPending, isError, data, error } = useAsset("my-awesome-sprite.png");
// or
const sprite = useSuspenseAsset("my-awesome-sprite.png"); Would make it very clear that you are opting into suspense, and if not, you have a nice pattern for handling the loading state within the component the OG way. FWIW, I am super into suspense and like typing fewer characters for my hook, but I don't think Suspense is the typical pattern in the react-pixi community today. Folks upgrading would have a better time with a non-suspense hook out of the gate until they jump on the suspense train. |
c795465
to
8c78809
Compare
This pull request is automatically built and testable in CodeSandbox. To see build info of the built libraries, click here or the icon next to each commit SHA. Latest deployment of this branch, based on commit 8c78809:
|
🎉 This issue has been resolved in version 8.0.0-beta.6 🎉 The release is available on GitHub release Your semantic-release bot 📦🚀 |
Description of change
This adds an
onError
callback to theuseAsset
hook. This allows us to handle errors within the related component instead of requiring an error boundary.Fixes: #501
Pre-Merge Checklist
npm run lint
)