App created with 'createSSRApp()' on the client side is not triggered beforeUnmount, unmounted hook. #5945
hiuny
started this conversation in
General Discussions
Replies: 1 comment 6 replies
-
Do you have any concrete use case in mind? A server-rendered component should not declare any long-running state. Not only for memory efficiency but also for isolation (one server typically renders apps for many users). On client-side, long-running states (like intervals/timeouts, subscriptions, global variables, etc.) should be initialized on the If you follow those best practices, the component state should be properly garbage-collected by the runtime (if not, it may be a bug). |
Beta Was this translation helpful? Give feedback.
6 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
In server-side rendering (ssr),
beforeUnmout
andunmounted
hooks do not occur (link1, link2). If youunmount()
the app, thebeforeUnmout
andunmounted
hooks do not occur. Isn't this a bit of a problem? This is because, in thebeforeUnmount
hook, code for the purpose of freeing memory can be executed. In the client, it may be possible to use thecreateApp()
function, but since this function emptys the html of the container (code1), it is not appropriate because the html content disappears for a while and then appears. When the client creates an app through thecreateSSRApp()
function, it seems appropriate to generate thebeforeUnmout
andunmounted
hooks. What do you think?link1
https://vuejs.org/api/composition-api-lifecycle.html#onbeforeunmount
link2
https://vuejs.org/api/composition-api-lifecycle.html#onunmounted
code1 -
createApp()
core/packages/runtime-dom/src/index.ts
Line 102 in c03459b
Beta Was this translation helpful? Give feedback.
All reactions