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
When data is changed in the parent but the template is actually rendered in a child, the updated hook of the parent will not trigger.
That means if the child component is a closed/external component (3rd party) there is no way to know when the DOM has been updated.
This is problematic when we rely on the render result to execute logic (generate custom print previews e.g.), as nextTick can be quite unpredictable and Vue's internal batching will prevent checking render results in a chain of updates.
The general advice now seems to watch for data changes, but as changed Data != DOM Update this does not help.
Would be great if we could register and access the child's hooks in the setup function of the parent (through a ref?), after the child has been mounted.
The text was updated successfully, but these errors were encountered:
LinusBorg
changed the title
VUE3: Provide access to lifecycle hooks of a child component (e.g. if 3rd party component)
Provide access to lifecycle hooks of a child component (e.g. if 3rd party component)
Aug 15, 2021
What problem does this feature solve?
When data is changed in the parent but the template is actually rendered in a child, the
updated hook
of the parent will not trigger.That means if the child component is a closed/external component (3rd party) there is no way to know when the DOM has been updated.
This is problematic when we rely on the render result to execute logic (generate custom print previews e.g.), as nextTick can be quite unpredictable and Vue's internal batching will prevent checking render results in a chain of updates.
The general advice now seems to watch for data changes, but as changed Data != DOM Update this does not help.
In vue2 I believe there was an
@hook:EVENT
that could be listened to from the parent.https://vuedose.tips/listen-to-lifecycle-hooks-on-third-party-vue-js-components
What does the proposed API look like?
<ChildComponent @hook:updated="doOnUpdated()" />
Would be great if we could register and access the child's hooks in the setup function of the parent (through a ref?), after the child has been mounted.
The text was updated successfully, but these errors were encountered: