Skip to content
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Syntax fix (#1)
* RFC: First class support for promises, async/await

Adds first class support for reading the result of a JavaScript Promise
using Suspense:

- Introduces support for async/await in Server Components. Write Server
  Components using standard JavaScript `await` syntax by defining your
  component as an async function.
- Introduces the `use` Hook. Like `await`, `use` unwraps the value of a
  promise, but it can be used inside normal components and Hooks,
  including on the client.

This enables React developers to access arbitrary asynchronous data
sources with Suspense via a stable API.

* Syntax fix

Co-authored-by: Andrew Clark <[email protected]>
  • Loading branch information
Artur93gev and acdlite authored Nov 4, 2022
commit 9c21ca1a8e39d19338ba750ee3ff6f6c0724a51c
2 changes: 1 addition & 1 deletion text/0000-first-class-support-for-promises.md
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ If JavaScript were to ever adopt a standard API for synchronously inspecting the

Tracking the result on the promise object only works if the promise object did not change between renders. If it's a brand new promise, then the previous strategies won't work. However, in many cases, even a brand new promise will already have resolved data. This happens often because most promise-based APIs return a fresh promise instance on every call regardless of whether the response was cached. That's also how async functions work in JavaScript — every call to an async function results in a brand new promise, even if the data was cached, and even if nothing was awaited at all.

The most important case where this happens is when an component re-renders in response to an unrelated update.
The most important case where this happens is when a component re-renders in response to an unrelated update.

Consider this example:

Expand Down