You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Sep 1, 2024. It is now read-only.
Render that component so that the deep propTypes are propType-invalid (eg <Example test={{}} /> for this example)
[tr1, str2, str3 and str4 are all required but not present, so all four are invalid.]
Expected
PropTypes warnings for all failed propTypes
For the example above this would be:
Warning: Failed prop type: The prop `str1` is marked as required in `Validator`, but its value is `undefined`.
Warning: Failed prop type: The prop `str2` is marked as required in `Validator`, but its value is `undefined`.
Warning: Failed prop type: The prop `str3` is marked as required in `Validator`, but its value is `undefined`.
Warning: Failed prop type: The prop `str4` is marked as required in `Validator`, but its value is `undefined`.
Actual
For deep propTypes only the first error is logged out, validation stops after that.
On the other hand, this is not true for shallow properties (like str1 and str2).
For the example above this is:
Warning: Failed prop type: The prop `str1` is marked as required in `Validator`, but its value is `undefined`.
Warning: Failed prop type: The prop `str2` is marked as required in `Validator`, but its value is `undefined`.
Warning: Failed prop type: The prop `str3` is marked as required in `Validator`, but its value is `undefined`.
/* Missing warning for str4! */
Note
This doesn't only trigger on required, but also on everything else, like .number, .string, ...
Setup / Replicate
Have a component with deep propTypes:
Render that component so that the deep propTypes are propType-invalid (eg
<Example test={{}} />
for this example)[
tr1
,str2
,str3
andstr4
are all required but not present, so all four are invalid.]Expected
PropTypes warnings for all failed propTypes
For the example above this would be:
Actual
For deep propTypes only the first error is logged out, validation stops after that.
On the other hand, this is not true for shallow properties (like
str1
andstr2
).For the example above this is:
Note
This doesn't only trigger on
required
, but also on everything else, like.number
,.string
, ...Second example
Full code (for copy-and-paste)
Cause of the bug
https://github.com/facebook/prop-types/blob/master/factoryWithTypeCheckers.js#L433
-> Exists on the first find opposed to
https://github.com/facebook/prop-types/blob/master/checkPropTypes.js#L44
-> loops through all, no return to be seen
[React calls this internally on validation, see https://github.com/facebook/react/blob/master/packages/react/src/ReactElementValidator.js#L218]
The text was updated successfully, but these errors were encountered: