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

Improve error message: Uncaught (in promise) Error: useTresContext must be used together with useTresContextProvider #878

Open
4 tasks done
andretchen0 opened this issue Dec 2, 2024 · 0 comments

Comments

@andretchen0
Copy link
Contributor

andretchen0 commented Dec 2, 2024

Problem

This message ...

Uncaught (in promise) Error: useTresContext must be used together with useTresContextProvider

... is emitted as an error whenever useTresContext is called without a provideing context. I.e., it's called without, or in the same file as a TresCanvas.

It's not only thrown when users call useTresContext, but also when they call anything that eventually touches useTresContext. This includes commonly used functions like useLoop.

But in that case, the error message doesn't point the user in a helpful direction.

Solution

  1. Offer constructive advise for fixing the most common problems that generate the message. Something like: "use* should be moved to a child component of `."
  2. Create a small write-up on tresjs.org. Link to the write-up in the error message.

Alternative

No response

Additional context

No response

Validations

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant