Sort keys in createStrictShapeTypeChecker message

Summary:
The keys were in random order which made this warning less useful when there are
many keys.

Reviewed By: spicyj

Differential Revision: D3504322

fbshipit-source-id: c184aa447c985a0149cbfa8c90c6daf9632b6226
This commit is contained in:
Jan Kassens 2016-07-01 15:38:11 -07:00 committed by Facebook Github Bot 1
parent bf79f87895
commit eb28c90205

View File

@ -46,14 +46,15 @@ function createStrictShapeTypeChecker(
var allKeys = merge(props[propName], shapeTypes);
for (var key in allKeys) {
var checker = shapeTypes[key];
if (!checker) {
invariant(
false,
`Invalid props.${propName} key \`${key}\` supplied to \`${componentName}\`.` +
`\nBad object: ` + JSON.stringify(props[propName], null, ' ') +
`\nValid keys: ` + JSON.stringify(Object.keys(shapeTypes), null, ' ')
);
}
invariant(
checker,
'Invalid props.%s key `%s` supplied to `%s`.\nBad object: %s\nValid keys: %s',
propName,
key,
componentName,
JSON.stringify(props[propName], null, ' '),
JSON.stringify(Object.keys(shapeTypes).sort(), null, ' '),
);
var error = checker(propValue, key, componentName, location);
if (error) {
invariant(