diff --git a/src/core/ReactPropTransferer.js b/src/core/ReactPropTransferer.js index c82e83dca6..a4f1ec5d94 100644 --- a/src/core/ReactPropTransferer.js +++ b/src/core/ReactPropTransferer.js @@ -22,6 +22,9 @@ var emptyFunction = require('emptyFunction'); var invariant = require('invariant'); var joinClasses = require('joinClasses'); var merge = require('merge'); +var warning = require('warning'); + +var didWarn = false; /** * Creates a transfer strategy that will merge prop values using the supplied @@ -141,6 +144,17 @@ var ReactPropTransferer = { descriptor.type.displayName ); + if (__DEV__) { + if (!didWarn) { + didWarn = true; + warning( + false, + 'transferPropsTo is deprecated. ' + + 'See http://fb.me/react-transferpropsto for more information.' + ); + } + } + // Because descriptors are immutable we have to merge into the existing // props object rather than clone it. transferInto(descriptor.props, this.props); diff --git a/src/core/__tests__/ReactPropTransferer-test.js b/src/core/__tests__/ReactPropTransferer-test.js index 940e85c9bd..ec2616ace4 100644 --- a/src/core/__tests__/ReactPropTransferer-test.js +++ b/src/core/__tests__/ReactPropTransferer-test.js @@ -28,13 +28,18 @@ var TestComponent; describe('ReactPropTransferer', function() { beforeEach(function() { + require('mock-modules').dumpCache(); + React = require('React'); ReactTestUtils = require('ReactTestUtils'); reactComponentExpect = require('reactComponentExpect'); + // We expect to get a warning from transferPropsTo since it's deprecated + spyOn(console, 'warn'); + TestComponent = React.createClass({ render: function() { - return this.transferPropsTo( + var result = this.transferPropsTo( ); + expect(console.warn).toHaveBeenCalled(); + return result; } }); });