Currently, registerComponent calls that throw have their errors swallowed by React if they occur in the call stack of a component render (due to the render triggering lazy evaluation of a top-level factory variable).
This can commonly happen if:
defaultProps throws
propTypes throws
can happen when consumedProps throws
Changes:
In _registerComponent and _registerComponent2, add a try-catch-rethrow that also logs the error, in case it's swallowed by React
Use print instead of window.console.error so it shows up in test output
In _registerComponent2 only: add more specific try-catch-rethrows around defaultProps/propTypes accesses, since that's usually what throws
Add regression tests that use the prints matcher to verify the error is printed
QA
[ ] CI passes, unit test coverage should be sufficient unless @greglittlefield-wf feels otherwise
Recommended review: Whitespace changes only
Problem
Currently, registerComponent calls that throw have their errors swallowed by React if they occur in the call stack of a component render (due to the render triggering lazy evaluation of a top-level factory variable).
This can commonly happen if:
Changes:
_registerComponent
and_registerComponent2
, add a try-catch-rethrow that also logs the error, in case it's swallowed by React_registerComponent2
only: add more specific try-catch-rethrows around defaultProps/propTypes accesses, since that's usually what throwsprints
matcher to verify the error is printedQA