Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[fail] reset IsThisRendererActing correctly #16042

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
15 changes: 15 additions & 0 deletions fixtures/dom/src/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,21 @@ it("doesn't warn when you use the right act + renderer: test", () => {
});
});

it('resets correctly across renderers', () => {
function Effecty() {
React.useEffect(() => {}, []);
return null;
}
TestUtils.act(() => {
TestRenderer.act(() => {});
expect(() => {
TestRenderer.create(<Effecty />);
}).toWarnDev(["It looks like you're using the wrong act()"], {
withoutStack: true,
});
});
});

it('warns when using createRoot() + .render', () => {
const root = ReactDOM.unstable_createRoot(document.createElement('div'));
expect(() => {
Expand Down
2 changes: 1 addition & 1 deletion packages/react-dom/src/test-utils/ReactTestUtilsAct.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ function act(callback: () => Thenable) {
actingUpdatesScopeDepth++;
if (__DEV__) {
previousIsSomeRendererActing = IsSomeRendererActing.current;
previousIsThisRendererActing = IsSomeRendererActing.current;
previousIsThisRendererActing = IsThisRendererActing.current;
IsSomeRendererActing.current = true;
IsThisRendererActing.current = true;
}
Expand Down
2 changes: 1 addition & 1 deletion packages/react-noop-renderer/src/createReactNoop.js
Original file line number Diff line number Diff line change
Expand Up @@ -620,7 +620,7 @@ function createReactNoop(reconciler: Function, useMutation: boolean) {
actingUpdatesScopeDepth++;
if (__DEV__) {
previousIsSomeRendererActing = IsSomeRendererActing.current;
previousIsThisRendererActing = IsSomeRendererActing.current;
previousIsThisRendererActing = IsThisRendererActing.current;
IsSomeRendererActing.current = true;
IsThisRendererActing.current = true;
}
Expand Down
2 changes: 1 addition & 1 deletion packages/react-test-renderer/src/ReactTestRendererAct.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ function act(callback: () => Thenable) {
actingUpdatesScopeDepth++;
if (__DEV__) {
previousIsSomeRendererActing = IsSomeRendererActing.current;
previousIsThisRendererActing = IsSomeRendererActing.current;
previousIsThisRendererActing = IsThisRendererActing.current;
IsSomeRendererActing.current = true;
IsThisRendererActing.current = true;
}
Expand Down