| 321 | let suspendedThenable: Thenable<any> | null = null; |
| 322 | let needsToResetSuspendedThenableDEV = false; |
| 323 | export function getSuspendedThenable(): Thenable<mixed> { |
| 324 | // This is called right after `use` suspends by throwing an exception. `use` |
| 325 | // throws an opaque value instead of the thenable itself so that it can't be |
| 326 | // caught in userspace. Then the work loop accesses the actual thenable using |
| 327 | // this function. |
| 328 | if (suspendedThenable === null) { |
| 329 | throw new Error( |
| 330 | 'Expected a suspended thenable. This is a bug in React. Please file ' + |
| 331 | 'an issue.', |
| 332 | ); |
| 333 | } |
| 334 | const thenable = suspendedThenable; |
| 335 | suspendedThenable = null; |
| 336 | if (__DEV__) { |
| 337 | needsToResetSuspendedThenableDEV = false; |
| 338 | } |
| 339 | return thenable; |
| 340 | } |
| 341 | |
| 342 | export function checkIfUseWrappedInTryCatch(): boolean { |
| 343 | if (__DEV__) { |