act()

A React test helper that runs a piece of code and then finishes all resulting renders and effects before you check the result.

In more detail

Wrapping root.render or a simulated click in act makes the page reflect the update, so the next line can read it. In React 19 act is imported from react, and the async form await act(async () => ...) also waits for promises.

Example

await act(async () => { root.render(<App />); });

Related terms

Taught in

References