Skip to content

Commit

Permalink
[fail] reset IsThisRendererActing correctly
Browse files Browse the repository at this point in the history
I missed this in facebook#16039. I'd pointed at the wrong previous state, corrupting it in further use. This PR fixes that, and adds a test to make sure it doesn't happen again.
  • Loading branch information
threepointone committed Jul 3, 2019
1 parent bd84645 commit fb493ee
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 3 deletions.
15 changes: 15 additions & 0 deletions fixtures/dom/src/index.test.js
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
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
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
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

0 comments on commit fb493ee

Please sign in to comment.