diff --git a/src/renderers/shared/reconciler/ReactCompositeComponent.js b/src/renderers/shared/reconciler/ReactCompositeComponent.js index f1c84438eb..ad2c53aeb7 100644 --- a/src/renderers/shared/reconciler/ReactCompositeComponent.js +++ b/src/renderers/shared/reconciler/ReactCompositeComponent.js @@ -257,6 +257,14 @@ var ReactCompositeComponentMixin = { if (inst.componentWillUnmount) { inst.componentWillUnmount(); } + if (__DEV__) { + warning( + typeof inst.componentDidUnmount !== 'function', + 'componentDidUnmount was defined on %s. But there is no such ' + + 'lifecycle method. Use componentWillUnmount instead.', + this.getName() || 'ReactCompositeComponent' + ); + } ReactReconciler.unmountComponent(this._renderedComponent); this._renderedComponent = null; diff --git a/src/renderers/shared/reconciler/__tests__/ReactCompositeComponent-test.js b/src/renderers/shared/reconciler/__tests__/ReactCompositeComponent-test.js index 15a56b60da..cc70e59ba5 100644 --- a/src/renderers/shared/reconciler/__tests__/ReactCompositeComponent-test.js +++ b/src/renderers/shared/reconciler/__tests__/ReactCompositeComponent-test.js @@ -552,6 +552,33 @@ describe('ReactCompositeComponent', function() { ); }); + it('should warn when defined method componentDidUnmount', function() { + var container = document.createElement('div'); + document.body.appendChild(container); + + var Component = React.createClass({ + componentDidUnmount: function() { + }, + + render: function() { + return
; + }, + }); + + var instance =