Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
Codemod act -> await act (2/?)
Similar to the rationale for `waitFor` (see #26285), we should always
await the result of an `act` call so that microtasks have a chance to
fire.

This only affects the internal `act` that we use in our repo, for now.
In the public `act` API, we don't yet require this; however, we
effectively will for any update that triggers suspense once `use` lands.
So we likely will start warning in an upcoming minor.
  • Loading branch information
acdlite committed Mar 7, 2023
commit 372cf23a397ebe6378a3b1e2a33c7239f5eb3a17
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ describe('ReactDOMServerSuspense', () => {
expect(divB.tagName).toBe('DIV');
expect(divB.textContent).toBe('B');

act(() => {
await act(async () => {
ReactDOMClient.hydrateRoot(parent, example);
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,23 +153,15 @@ describe('ReactDOMSuspensePlaceholder', () => {
);
}

act(() => {
await act(async () => {
ReactDOM.render(<App />, container);
});
expect(container.innerHTML).toEqual(
'<span style="display: none;">Sibling</span><span style=' +
'"display: none;"></span>Loading...',
);

act(() => setIsVisible(true));
expect(container.innerHTML).toEqual(
'<span style="display: none;">Sibling</span><span style=' +
'"display: none;"></span>Loading...',
);

await advanceTimers(500);

Scheduler.unstable_flushAll();
await act(async () => setIsVisible(true));

expect(container.innerHTML).toEqual(
'<span style="display: inline;">Sibling</span><span style="">Async</span>',
Expand Down
Loading