Skip to content
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

Merged
merged 12 commits into from
Aug 1, 2024

Conversation

trezy
Copy link
Collaborator

@trezy trezy commented Jul 17, 2024

Description of change

This adds an onError callback to the useAsset hook. This allows us to handle errors within the related component instead of requiring an error boundary.

Fixes: #501

Pre-Merge Checklist
  • Documentation is changed or added
  • Lint process passed (npm run lint)

@trezy trezy added the enhancement New feature or request label Jul 17, 2024
@trezy trezy self-assigned this Jul 17, 2024
github-actions[bot]

This comment was marked as spam.

@trezy
Copy link
Collaborator Author

trezy commented Jul 17, 2024

@thejustinwalsh, I'd love feedback from you on the solution here.

@thejustinwalsh
Copy link

thejustinwalsh commented Jul 19, 2024

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...
useAsset(s) and useSuspenseAsset(s)

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.

@trezy trezy added the v8 Issues related to Pixi React v8 label Jul 26, 2024
@trezy trezy force-pushed the 501-feature-request-error-handling-for-useasset branch from c795465 to 8c78809 Compare August 1, 2024 03:15
Copy link

codesandbox-ci bot commented Aug 1, 2024

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:

Sandbox Source
pixi.js-sandbox Configuration

@trezy trezy merged commit 4e71c18 into beta Aug 1, 2024
4 checks passed
@trezy trezy deleted the 501-feature-request-error-handling-for-useasset branch August 1, 2024 03:17
Copy link

github-actions bot commented Aug 1, 2024

🎉 This issue has been resolved in version 8.0.0-beta.6 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request released on @beta v8 Issues related to Pixi React v8
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants