diff --git a/src/core/ReactComponent.js b/src/core/ReactComponent.js
index d8c883b6d4..2f048502e6 100644
--- a/src/core/ReactComponent.js
+++ b/src/core/ReactComponent.js
@@ -278,6 +278,10 @@ var ReactComponent = {
'`render` method to pass the correct value as props to the component ' +
'where it is created.'
);
+ invariant(
+ this.isMounted(),
+ 'replaceProps(...): Can only update a mounted component.'
+ );
this._pendingProps = props;
ReactUpdates.enqueueUpdate(this, callback);
},
diff --git a/src/core/__tests__/ReactComponentLifeCycle-test.js b/src/core/__tests__/ReactComponentLifeCycle-test.js
index 3f2df5e82e..d6bce0d267 100644
--- a/src/core/__tests__/ReactComponentLifeCycle-test.js
+++ b/src/core/__tests__/ReactComponentLifeCycle-test.js
@@ -408,6 +408,27 @@ describe('ReactComponentLifeCycle', function() {
.toThrow();
});
+ it('should throw when calling setProps() on an unmounted component',
+ function() {
+ var PropsToUpdate = React.createClass({
+ render: function() {
+ return (
+
+
+ );
+ }
+ });
+ var instance = ;
+ expect(function() {
+ instance.setProps({value: "goodbye"});
+ }).toThrow(
+ 'Invariant Violation: replaceProps(...): Can only update a ' +
+ 'mounted component.'
+ );
+ });
+
it('should allow state updates in componentDidMount', function() {
/**
* calls setState in an componentDidMount.