MCPcopy
hub / github.com/facebook/react / act

Function act

packages/react-devtools-shared/src/__tests__/utils.js:67–92  ·  view source on GitHub ↗
(
  callback: Function,
  recursivelyFlush: boolean = true,
)

Source from the content-addressed store, hash-verified

65}
66
67export function act(
68 callback: Function,
69 recursivelyFlush: boolean = true,
70): void {
71 // act from react-test-renderer has some side effects on React DevTools
72 // it injects the renderer for DevTools, see ReactTestRenderer.js
73 const actTestRenderer = getActTestRendererImplementation();
74 const actDOM = getActDOMImplementation();
75
76 actDOM(() => {
77 actTestRenderer(() => {
78 callback();
79 });
80 });
81
82 if (recursivelyFlush) {
83 // Flush Bridge operations
84 while (jest.getTimerCount() > 0) {
85 actDOM(() => {
86 actTestRenderer(() => {
87 jest.runAllTimers();
88 });
89 });
90 }
91 }
92}
93
94export async function actAsync(
95 cb: () => *,

Callers 15

LeafFunction · 0.70
store-test.jsFile · 0.70
ChildFunction · 0.70
renderFunction · 0.70
patchFunction · 0.70
GrandparentFunction · 0.70
BarFunction · 0.70

Calls 4

getActDOMImplementationFunction · 0.85
runAllTimersMethod · 0.80
callbackFunction · 0.50

Tested by

no test coverage detected