Make transferPropsTo() message easier to debug

Summary:
Made the transferPropsTo() error introduced in
325322898c easier to use to debug.
This commit is contained in:
Keito Uchiyama
2013-10-09 11:28:35 -07:00
committed by Paul O’Shannessy
parent 7a9c13dee8
commit ef60eee57a
2 changed files with 7 additions and 4 deletions
+5 -3
View File
@@ -93,9 +93,11 @@ var ReactPropTransferer = {
transferPropsTo: function(component) {
invariant(
component.props.__owner__ === this,
'You can\'t call transferPropsTo() on a component that you don\'t ' +
'own. This usually means you are calling transferPropsTo() on a ' +
'component passed in as props or children.'
'%s: You can\'t call transferPropsTo() on a component that you ' +
'don\'t own, %s. This usually means you are calling ' +
'transferPropsTo() on a component passed in as props or children.',
this.constructor.displayName,
component.constructor.displayName
);
var props = {};
@@ -148,7 +148,8 @@ describe('ReactPropTransferer', function() {
ReactTestUtils.renderIntoDocument(<Parent />);
}).toThrow(
'Invariant Violation: ' +
'You can\'t call transferPropsTo() on a component that you don\'t own. ' +
'Child: You can\'t call transferPropsTo() on a component that you ' +
'don\'t own, span. ' +
'This usually means you are calling transferPropsTo() on a component ' +
'passed in as props or children.'
);