diff --git a/scripts/fiber/tests-failing.txt b/scripts/fiber/tests-failing.txt index 67febc8fb3..8401824c78 100644 --- a/scripts/fiber/tests-failing.txt +++ b/scripts/fiber/tests-failing.txt @@ -1,9 +1,6 @@ src/isomorphic/classic/__tests__/ReactContextValidator-test.js * should pass previous context to lifecycles -src/renderers/__tests__/ReactComponentLifeCycle-test.js -* should carry through each of the phases of setup - src/renderers/__tests__/ReactComponentTreeHook-test.js * can be retrieved by ID diff --git a/scripts/fiber/tests-passing.txt b/scripts/fiber/tests-passing.txt index 238fe2bde4..6d5d522b70 100644 --- a/scripts/fiber/tests-passing.txt +++ b/scripts/fiber/tests-passing.txt @@ -551,6 +551,7 @@ src/renderers/__tests__/ReactComponentLifeCycle-test.js * should correctly determine if a null component is mounted * isMounted should return false when unmounted * warns if findDOMNode is used inside render +* should carry through each of the phases of setup * should not throw when updating an auxiliary component * should allow state updates in componentDidMount * should call nested lifecycle methods in the right order diff --git a/src/renderers/__tests__/ReactComponentLifeCycle-test.js b/src/renderers/__tests__/ReactComponentLifeCycle-test.js index 8497d33a70..7c6c06cf75 100644 --- a/src/renderers/__tests__/ReactComponentLifeCycle-test.js +++ b/src/renderers/__tests__/ReactComponentLifeCycle-test.js @@ -13,7 +13,6 @@ var React; var ReactDOM; -var ReactInstanceMap; var ReactTestUtils; var clone = function(o) { @@ -78,12 +77,9 @@ type ComponentLifeCycle = 'UNMOUNTED'; function getLifeCycleState(instance): ComponentLifeCycle { - var internalInstance = ReactInstanceMap.get(instance); - // Once a component gets mounted, it has an internal instance, once it - // gets unmounted, it loses that internal instance. - return internalInstance ? - 'MOUNTED' : - 'UNMOUNTED'; + return instance.updater.isMounted(instance) ? + 'MOUNTED' : + 'UNMOUNTED'; } /** @@ -99,7 +95,6 @@ describe('ReactComponentLifeCycle', () => { React = require('React'); ReactDOM = require('ReactDOM'); ReactTestUtils = require('ReactTestUtils'); - ReactInstanceMap = require('ReactInstanceMap'); }); it('should not reuse an instance when it has been unmounted', () => { @@ -336,6 +331,9 @@ describe('ReactComponentLifeCycle', () => { }); it('should carry through each of the phases of setup', () => { + spyOn(console, 'error'); + + class LifeCycleComponent extends React.Component { constructor(props, context) { super(props, context); @@ -410,7 +408,7 @@ describe('ReactComponentLifeCycle', () => { instance._testJournal.returnedFromGetInitialState ); expect(instance._testJournal.lifeCycleAtStartOfWillMount) - .toBe('MOUNTED'); + .toBe('UNMOUNTED'); // componentDidMount expect(instance._testJournal.stateAtStartOfDidMount) @@ -419,11 +417,11 @@ describe('ReactComponentLifeCycle', () => { 'MOUNTED' ); - // render + // initial render expect(instance._testJournal.stateInInitialRender) .toEqual(INIT_RENDER_STATE); expect(instance._testJournal.lifeCycleInInitialRender).toBe( - 'MOUNTED' + 'UNMOUNTED' ); expect(getLifeCycleState(instance)).toBe('MOUNTED'); @@ -452,6 +450,11 @@ describe('ReactComponentLifeCycle', () => { // But the current lifecycle of the component is unmounted. expect(getLifeCycleState(instance)).toBe('UNMOUNTED'); expect(instance.state).toEqual(POST_WILL_UNMOUNT_STATE); + + expectDev(console.error.calls.count()).toBe(1); + expectDev(console.error.calls.argsFor(0)[0]).toContain( + 'LifeCycleComponent is accessing isMounted inside its render() function' + ); }); it('should not throw when updating an auxiliary component', () => {