mirror of
https://github.com/status-im/react-native.git
synced 2025-02-04 21:53:30 +00:00
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:
parent
bf79f87895
commit
eb28c90205
@ -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(
|
||||
|
Loading…
x
Reference in New Issue
Block a user