Warning message updated if defaultProps were defined as an instance property (#9493)
* Updated the warning message for setting defaultProps on instance property. * Updated the testcases for the defaultProps warning. * Updated the warning message for defaultProps set on instance property.
Abhay Nikam committed
May 2, 2017 at 00:00 UTC
1f5693ec670f22e30d1d52a8554032ab0383b9af
3 files changed
+8
-6
src/renderers/__tests__/ReactCompositeComponent-test.js
+2
-2
@@ -504,8 +504,8 @@ describe('ReactCompositeComponent', () => {
504
505
expectDev(console.error.calls.count()).toBe(1);
506
expectDev(console.error.calls.argsFor(0)[0]).toBe(
507
- 'Warning: defaultProps was defined as an instance property ' +
508
- 'on Component. Use a static property to define defaultProps instead.',
507
+ 'Warning: setting defaultProps as an instance property on Component is not supported ' +
508
+ 'and will be ignored. Instead, define defaultProps as a static property on Component.',
509
);
510
});
511
src/renderers/shared/fiber/ReactFiberClassComponent.js
+3
-2
@@ -245,8 +245,9 @@ module.exports = function(
245
const noInstanceDefaultProps = !instance.defaultProps;
246
warning(
247
noInstanceDefaultProps,
248
- 'defaultProps was defined as an instance property on %s. Use a static ' +
249
- 'property to define defaultProps instead.',
248
+ 'setting defaultProps as an instance property on %s is not supported and will be ignored.' +
249
+ ' Instead, define defaultProps as a static property on %s.',
250
+ name,
251
name,
252
);
253
}
src/renderers/shared/stack/reconciler/ReactCompositeComponent.js
+3
-2
@@ -313,8 +313,9 @@ var ReactCompositeComponent = {
313
}
314
warning(
315
!inst.defaultProps,
316
- 'defaultProps was defined as an instance property on %s. Use a static ' +
317
- 'property to define defaultProps instead.',
316
+ 'setting defaultProps as an instance property on %s is not supported and will be ignored.' +
317
+ ' Instead, define defaultProps as a static property on %s.',
318
+ this.getName() || 'a component',
319
this.getName() || 'a component',
320
);
321
}