-
Notifications
You must be signed in to change notification settings - Fork 47k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Warn about unresolved function as a child #10376
Conversation
@@ -493,4 +493,78 @@ describe('ReactComponent', () => { | |||
' in Foo (at **)', | |||
); | |||
}); | |||
|
|||
if (ReactDOMFeatureFlags.useFiber) { | |||
fdescribe('with new features', () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
-f
Ran Jest internally with a |
@@ -200,6 +200,16 @@ function throwOnInvalidObjectType(returnFiber: Fiber, newChild: Object) { | |||
} | |||
} | |||
|
|||
function warnOnFunctionType() { | |||
warning( | |||
false, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not pass in newChild and put typeof newChild !== 'function'
instead of false
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To avoid two extra functions calls in DEV. (It's small but can add up.)
Also I find our warning
notation with falsy condition meaning a failure very confusing. I try to avoid it whenever I write warnings, and always use warning(false
so it’s clear from outer condition in which case it executes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I had one question, but I think this makes sense overall. Good tests! :)
@gaearon |
Fixes #9577.