Skip to content

Commit 4a862c0

Browse files
authored
Update act() usage to be async in examples
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.
1 parent b440d66 commit 4a862c0

File tree

1 file changed

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

1 file changed

+2
-2
lines changed

src/content/reference/react/act.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ it('can render and update a counter', async () => {
9898
document.body.appendChild(container);
9999

100100
// ✅ Render the component inside act().
101-
await act(() => {
101+
await act(async () => {
102102
ReactDOMClient.createRoot(container).render(<Counter />);
103103
});
104104

@@ -126,7 +126,7 @@ it.only('can render and update a counter', async () => {
126126
const container = document.createElement('div');
127127
document.body.appendChild(container);
128128

129-
await act( async () => {
129+
await act(async () => {
130130
ReactDOMClient.createRoot(container).render(<Counter />);
131131
});
132132

0 commit comments

Comments
 (0)