Skip to content

Commit d74a592

Browse files
committed
target audience
1 parent 12aa604 commit d74a592

File tree

1 file changed

+2
-0
lines changed
  • src/content/reference/react

1 file changed

+2
-0
lines changed

src/content/reference/react/use.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -438,6 +438,8 @@ To use the Promise's <CodeStep step={1}>`catch`</CodeStep> method, call <CodeSte
438438
439439
### Avoiding fallbacks by passing Promise subclasses {/*avoiding-fallbacks-by-passing-promise-subclasses*/}
440440
441+
If you are implementing a Suspense-enabled library, you can help React avoid unnecessarily suspending when you know the Promise has already settled, by using `status` and `value` or `reason` fields.
442+
441443
React will read the `status` field on Promise subclasses to synchronously read the value without waiting for a microtask. If the Promise is already settled (resolved or rejected), React can read the value immediately without suspending and showing a fallback if the update was not part of a Transition (e.g. [`ReactDOM.flushSync()`](/reference/react-dom/flushSync)).
442444
443445
React will set the `status` field itself if the passed Promise does not have this field set. Suspense-enabled libraries should set the `status` field on the Promises they create to avoid unnecessary fallbacks.

0 commit comments

Comments
 (0)