-
Notifications
You must be signed in to change notification settings - Fork 47.2k
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
Fix useImperativeHandle to have no deps by default #14801
Conversation
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.
You checked the shallow renderer and server renderer too?
@@ -905,7 +905,7 @@ function mountImperativeHandle<T>( | |||
|
|||
// TODO: If deps are provided, should we skip comparing the ref itself? | |||
const effectDeps = | |||
deps !== null && deps !== undefined ? deps.concat([ref]) : [ref]; | |||
deps !== null && deps !== undefined ? deps.concat([ref]) : deps; |
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.
deps !== null && deps !== undefined ? deps.concat([ref]) : deps; | |
deps !== null && deps !== undefined ? deps.concat([ref]) : null; |
Nit: Should only be null, not undefined. I wondered why this wasn't a type error but it's because mountEffectImpl
and updateEffectImpl
contain their own type check; we might inline those later.
@@ -931,7 +931,7 @@ function updateImperativeHandle<T>( | |||
|
|||
// TODO: If deps are provided, should we skip comparing the ref itself? | |||
const effectDeps = | |||
deps !== null && deps !== undefined ? deps.concat([ref]) : [ref]; | |||
deps !== null && deps !== undefined ? deps.concat([ref]) : deps; |
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.
Same as above
Just checked — both are noops. |
Fixes #14782. If nothing is provided, there should be no dependencies — not
[ref]
alone.