Skip to content

Fix error messages logged by failed prop type checks#2434

Merged
robertknight merged 2 commits intomasterfrom
fix-check-prop-types-args
Apr 1, 2020
Merged

Fix error messages logged by failed prop type checks#2434
robertknight merged 2 commits intomasterfrom
fix-check-prop-types-args

Conversation

@robertknight
Copy link
Copy Markdown
Member

The error message logged when a value of an incorrect type is passed as
the prop propName for a component Widget should read:

Failed prop type: Invalid prop `propName` supplied to `Widget`

Instead it read:

Failed Widget type: Invalid Widget `propName` supplied to `Widget`

The issue was that the wrong parameters were passed to checkPropType.

@github-actions
Copy link
Copy Markdown

github-actions Bot commented Apr 1, 2020

Size Change: +70 B (0%)

Total Size: 38.7 kB

Filename Size Change
debug/dist/debug.js 3 kB +14 B (0%)
debug/dist/debug.module.js 2.98 kB +22 B (0%)
debug/dist/debug.umd.js 3.08 kB +34 B (1%)
ℹ️ View Unchanged
Filename Size Change
compat/dist/compat.js 3.12 kB 0 B
compat/dist/compat.module.js 3.14 kB 0 B
compat/dist/compat.umd.js 3.17 kB 0 B
devtools/dist/devtools.js 175 B 0 B
devtools/dist/devtools.module.js 185 B 0 B
devtools/dist/devtools.umd.js 252 B 0 B
dist/preact.js 3.72 kB 0 B
dist/preact.min.js 3.72 kB 0 B
dist/preact.module.js 3.73 kB 0 B
dist/preact.umd.js 3.79 kB 0 B
hooks/dist/hooks.js 1.05 kB 0 B
hooks/dist/hooks.module.js 1.08 kB 0 B
hooks/dist/hooks.umd.js 1.12 kB 0 B
test-utils/dist/testUtils.js 437 B 0 B
test-utils/dist/testUtils.module.js 439 B 0 B
test-utils/dist/testUtils.umd.js 515 B 0 B

compressed-size-action

Comment thread debug/src/check-props.js
Comment thread debug/src/debug.js
vnode.props,
getDisplayName(vnode),
serializeVNode(vnode)
'prop',
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TIL that "prop types" can also be used to check things that are not props, such as context. See https://github.com/facebook/prop-types/blob/1c4077b7455e037bd8f81f48e9c51d60c972f8e9/checkPropTypes.js#L37.

The error message logged when a value of an incorrect type is passed as
the prop `propName` for a component `Widget` should read:

```
Failed prop type: Invalid prop `propName` supplied to `Widget`
```

Instead it read:

```
Failed Widget type: Invalid Widget `propName` supplied to `Widget`
```
@robertknight robertknight force-pushed the fix-check-prop-types-args branch from f57298e to a6016b6 Compare April 1, 2020 09:25
@robertknight robertknight merged commit a299d1d into master Apr 1, 2020
@robertknight robertknight deleted the fix-check-prop-types-args branch April 1, 2020 09:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants