Skip to content

Conversation

@valgaze
Copy link

@valgaze valgaze commented Nov 14, 2025

This 🐣 PR updates the second example on react.dev/reference/react/act to use an async callback with act() + fix an alignment issue with another sample

Although the example currently uses a synchronous callback, the documentation below it explicitly recommends always using the async form:

“We recommend using act with await and an async function.
Although the sync version works in many cases, it doesn’t work in all cases…
We will deprecate and remove the sync version in the future.”

Updating the example to use an async callback makes it consistent with:

  • The guidance above
  • Other examples on the page
  • The future direction of the API (nobody should do a double-take when the 1st example uses a sync callback)

This change does not alter the behavior of the example, but aligns it with the recommended best practice and helps avoid confusion for readers.

The second example uses a synchronous callback to act(), but the docs recommend always using the async version and mention the sync form will be deprecated.

This PR updates the example so the callback is async for consistency with current React recommendations.
@github-actions
Copy link

Size changes

📦 Next.js Bundle Analysis for react-dev

This analysis was generated by the Next.js Bundle Analysis action. 🤖

This PR introduced no changes to the JavaScript bundle! 🙌

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant