Skip to content

Commit

Permalink
Syntax fix (#1)
Browse files Browse the repository at this point in the history
* 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 <git@andrewclark.io>
  • Loading branch information
Artur93gev and acdlite authored Nov 4, 2022
1 parent 5c123c6 commit 9c21ca1
Showing 1 changed file with 1 addition and 1 deletion.
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

0 comments on commit 9c21ca1

Please sign in to comment.