Open JasonGotGithub opened 4 months ago
Without an explanation is quite difficult to understand what your intention is of your message @linzhe141 Besides that, the problem of this issue still occurs in your link
I think they just provided a simplified reproduction that doesn't involve a router etc. Which is helpful.
Ah okay, makes sense. I agree
@LinusBorg @linzhe141 Out of curiosity, what would be the process to solve this bug?
The ref
is set to null
when the component unmounts. Transition leave
hooks are triggered when the element is removed.
In your example, when you click the about
button, the process is as follows:
pageRef
is set to null)leave
and afterLeave
hooksThis behavior for updating the ref
is expected.
By the way, I'm curious why you need to access the ref
in the leave
hook. Perhaps there's another way to achieve your goal?
Hi @jh-leong, thanks for your comment.
Is this different from Vue 2? In Vue 2 refs are available in the leave
hooks, which would then be the "opposite" from how it is now. I assume since the destroy sequence is no longer present in Vue 3, that's where the different is?
The reason for making this issue, is that quite some creative developers are having issues with Vue 3 and its transition logic. For certain creative transitions/effects, data from the previous/leaving page are required (e.g. WebGL, page transitions, doing a specific animation of elements on the previous page). Simple example: collecting mouse/animation data to proceed an effect on a new page.
Hi @jh-leong!
Is the reason clear or do you want more clarification?
Sorry for the late response.
Is this different from Vue 2? In Vue 2 refs are available in the leave hooks, which would then be the "opposite" from how it is now. I assume since the destroy sequence is no longer present in Vue 3, that's where the different is?
I'm not familiar with Vue 2, so I can't answer this question directly.
The reason for making this issue, is that quite some creative developers are having issues with Vue 3 and its transition logic. For certain creative transitions/effects, data from the previous/leaving page are required (e.g. WebGL, page transitions, doing a specific animation of elements on the previous page). Simple example: collecting mouse/animation data to proceed an effect on a new page.
If you need to access data from the previous page in the leave
hook, maybe function refs
could be a workaround. Check out this playground.
Thanks! I'll take a look this week
This behavior is different from vue2. see https://codesandbox.io/p/sandbox/vue-2-playground-forked-2jn5f7?workspaceId=28b40334-b6d1-4971-a748-f2552025b31c
Vue version
v3.4.31
Link to minimal reproduction
https://stackblitz.com/edit/github-gyqmpz-bdzdrb?file=src%2Fpages%2FAbout.vue
Steps to reproduce
Clicking on the navigation link will trigger navigating. In the console the refs for the pages will be logged
What is expected?
The expected behavior is that the refs should trigger errors and have content within it
What is actually happening?
The refs are empty
System Info
No response
Any additional comments?
No response