Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit c555c00

Browse files
Sunil Paigaearon
Sunil Pai
authored andcommitted
Include component stack in 'act(...)' warning (facebook#14855)
* add a component stack trace to the act() warning * pass tests * nit
1 parent ff188d6 commit c555c00

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

packages/react-dom/src/__tests__/ReactTestUtils-test.js

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -634,10 +634,9 @@ describe('ReactTestUtils', () => {
634634
button.dispatchEvent(new MouseEvent('click', {bubbles: true}));
635635
});
636636
expect(button.innerHTML).toBe('2');
637-
expect(() => setValueRef(1)).toWarnDev(
638-
['An update to App inside a test was not wrapped in act(...).'],
639-
{withoutStack: 1},
640-
);
637+
expect(() => setValueRef(1)).toWarnDev([
638+
'An update to App inside a test was not wrapped in act(...).',
639+
]);
641640
document.body.removeChild(container);
642641
});
643642

packages/react-reconciler/src/ReactFiberScheduler.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1839,8 +1839,10 @@ export function warnIfNotCurrentlyBatchingInDev(fiber: Fiber): void {
18391839
'});\n' +
18401840
'/* assert on the output */\n\n' +
18411841
"This ensures that you're testing the behavior the user would see in the browser." +
1842-
' Learn more at https://fb.me/react-wrap-tests-with-act',
1842+
' Learn more at https://fb.me/react-wrap-tests-with-act' +
1843+
'%s',
18431844
getComponentName(fiber.type),
1845+
getStackByFiberInDevAndProd(fiber),
18441846
);
18451847
}
18461848
}

0 commit comments

Comments
 (0)