From 361ce5c00bd39942a7417dd635503e59e058267b Mon Sep 17 00:00:00 2001 From: Ben Alpert Date: Thu, 1 Dec 2016 14:19:00 -0800 Subject: [PATCH] Add test for unmount/remount in a single batch (#8470) Fails in Fiber. --- scripts/fiber/tests-failing.txt | 1 + .../shared/shared/__tests__/ReactUpdates-test.js | 10 ++++++++++ 2 files changed, 11 insertions(+) diff --git a/scripts/fiber/tests-failing.txt b/scripts/fiber/tests-failing.txt index b397e754bec48..0aba62db6feb1 100644 --- a/scripts/fiber/tests-failing.txt +++ b/scripts/fiber/tests-failing.txt @@ -115,6 +115,7 @@ src/renderers/shared/shared/__tests__/ReactUpdates-test.js * throws in setState if the update callback is not a function * throws in replaceState if the update callback is not a function * throws in forceUpdate if the update callback is not a function +* unmounts and remounts a root in the same batch src/renderers/shared/shared/__tests__/refs-test.js * Should increase refs with an increase in divs diff --git a/src/renderers/shared/shared/__tests__/ReactUpdates-test.js b/src/renderers/shared/shared/__tests__/ReactUpdates-test.js index 97f72a2e2a087..a430c1923c2a1 100644 --- a/src/renderers/shared/shared/__tests__/ReactUpdates-test.js +++ b/src/renderers/shared/shared/__tests__/ReactUpdates-test.js @@ -1081,4 +1081,14 @@ describe('ReactUpdates', () => { }); expect(result).toEqual(42); }); + + it('unmounts and remounts a root in the same batch', () => { + var container = document.createElement('div'); + ReactDOM.render(a, container); + ReactDOM.unstable_batchedUpdates(function() { + ReactDOM.unmountComponentAtNode(container); + ReactDOM.render(b, container); + }); + expect(container.textContent).toBe('b'); + }); });