-
Notifications
You must be signed in to change notification settings - Fork 48.4k
Fix useImperativeHandle to have no deps by default #14801
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
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.