You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The old (unstable) mechanism for suspending was to throw a promise. The
purpose of throwing is to interrupt the component's execution, and also
to signal to React that the interruption was caused by Suspense as
opposed to some other error.
A flaw is that throwing is meant to be an implementation details — if
code in userspace catches the promise, it can lead to
unexpected behavior.
With `use`, userspace code does not throw promises directly, but `use`
itself still needs to throw something to interrupt the component and
unwind the stack.
The solution is to throw an opaque object. In development, we can detect
whether the object was caught by a userspace try/catch block and log a
warning — though it's not foolproof, since a clever user could catch the
object and rethrow it later.
I did not yet implement the warning in Flight.
0 commit comments