Skip to content

Commit ddb1c74

Browse files
committed
Merge pull request #2960 from jsfb/add-detectable-prefix-to-reactelement-warning
Add detectable prefix to ReactElement proptype warning.
2 parents bab59cd + b2f77e6 commit ddb1c74

4 files changed

Lines changed: 23 additions & 12 deletions

File tree

src/classic/element/ReactElementValidator.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,7 @@ function checkPropTypes(componentName, propTypes, props, location) {
269269
loggedTypeFailures[error.message] = true;
270270

271271
var addendum = getDeclarationErrorAddendum(this);
272-
warning(false, error.message + addendum);
272+
warning(false, 'Failed propType: ' + error.message + addendum);
273273
}
274274
}
275275
}

src/classic/element/__tests__/ReactElementValidator-test.js

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,8 @@ describe('ReactElementValidator', function() {
206206
});
207207
ReactTestUtils.renderIntoDocument(React.createElement(ParentComp));
208208
expect(console.warn.calls[0].args[0]).toBe(
209-
'Warning: Invalid prop `color` of type `number` supplied to `MyComp`, ' +
209+
'Warning: Failed propType: ' +
210+
'Invalid prop `color` of type `number` supplied to `MyComp`, ' +
210211
'expected `string`. Check the render method of `ParentComp`.'
211212
);
212213
});
@@ -247,7 +248,8 @@ describe('ReactElementValidator', function() {
247248

248249
expect(console.warn.calls.length).toBe(1);
249250
expect(console.warn.calls[0].args[0]).toBe(
250-
'Warning: Required prop `prop` was not specified in `Component`.'
251+
'Warning: Failed propType: ' +
252+
'Required prop `prop` was not specified in `Component`.'
251253
);
252254
});
253255

@@ -270,7 +272,8 @@ describe('ReactElementValidator', function() {
270272

271273
expect(console.warn.calls.length).toBe(1);
272274
expect(console.warn.calls[0].args[0]).toBe(
273-
'Warning: Required prop `prop` was not specified in `Component`.'
275+
'Warning: Failed propType: ' +
276+
'Required prop `prop` was not specified in `Component`.'
274277
);
275278
});
276279

@@ -295,11 +298,13 @@ describe('ReactElementValidator', function() {
295298

296299
expect(console.warn.calls.length).toBe(2);
297300
expect(console.warn.calls[0].args[0]).toBe(
298-
'Warning: Required prop `prop` was not specified in `Component`.'
301+
'Warning: Failed propType: ' +
302+
'Required prop `prop` was not specified in `Component`.'
299303
);
300304

301305
expect(console.warn.calls[1].args[0]).toBe(
302-
'Warning: Invalid prop `prop` of type `number` supplied to ' +
306+
'Warning: Failed propType: ' +
307+
'Invalid prop `prop` of type `number` supplied to ' +
303308
'`Component`, expected `string`.'
304309
);
305310

src/classic/types/__tests__/ReactPropTypes-test.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -752,7 +752,8 @@ describe('ReactPropTypes', function() {
752752
var instance = <Component num={6} />;
753753
instance = ReactTestUtils.renderIntoDocument(instance);
754754
expect(console.warn.argsForCall.length).toBe(1);
755-
expect(console.warn.argsForCall[0][0]).toBe('Warning: num must be 5!');
755+
expect(console.warn.argsForCall[0][0]).toBe(
756+
'Warning: Failed propType: num must be 5!');
756757
});
757758

758759
it('should not warn if the validator returned anything else than an error',

src/modern/element/__tests__/ReactJSXElementValidator-test.js

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,8 @@ describe('ReactJSXElementValidator', function() {
196196
}
197197
ReactTestUtils.renderIntoDocument(<ParentComp />);
198198
expect(console.warn.calls[0].args[0]).toBe(
199-
'Warning: Invalid prop `color` of type `number` supplied to `MyComp`, ' +
199+
'Warning: Failed propType: ' +
200+
'Invalid prop `color` of type `number` supplied to `MyComp`, ' +
200201
'expected `string`. Check the render method of `ParentComp`.'
201202
);
202203
});
@@ -236,7 +237,8 @@ describe('ReactJSXElementValidator', function() {
236237

237238
expect(console.warn.calls.length).toBe(1);
238239
expect(console.warn.calls[0].args[0]).toBe(
239-
'Warning: Required prop `prop` was not specified in `Component`.'
240+
'Warning: Failed propType: ' +
241+
'Required prop `prop` was not specified in `Component`.'
240242
);
241243
});
242244

@@ -255,7 +257,8 @@ describe('ReactJSXElementValidator', function() {
255257

256258
expect(console.warn.calls.length).toBe(1);
257259
expect(console.warn.calls[0].args[0]).toBe(
258-
'Warning: Required prop `prop` was not specified in `Component`.'
260+
'Warning: Failed propType: ' +
261+
'Required prop `prop` was not specified in `Component`.'
259262
);
260263
});
261264

@@ -276,11 +279,13 @@ describe('ReactJSXElementValidator', function() {
276279

277280
expect(console.warn.calls.length).toBe(2);
278281
expect(console.warn.calls[0].args[0]).toBe(
279-
'Warning: Required prop `prop` was not specified in `Component`.'
282+
'Warning: Failed propType: ' +
283+
'Required prop `prop` was not specified in `Component`.'
280284
);
281285

282286
expect(console.warn.calls[1].args[0]).toBe(
283-
'Warning: Invalid prop `prop` of type `number` supplied to ' +
287+
'Warning: Failed propType: ' +
288+
'Invalid prop `prop` of type `number` supplied to ' +
284289
'`Component`, expected `string`.'
285290
);
286291

0 commit comments

Comments
 (0)