From fb1ac8c5956a07662c77590b16d53c7f799991e3 Mon Sep 17 00:00:00 2001 From: Damian Stasik Date: Mon, 29 Apr 2019 00:03:06 +0200 Subject: [PATCH] Add `serverPrefetch` to list of lifecycle hooks called during SSR --- docs/guide/universal.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/guide/universal.md b/docs/guide/universal.md index 5100a2e9..6ead676d 100644 --- a/docs/guide/universal.md +++ b/docs/guide/universal.md @@ -10,7 +10,7 @@ Because the actual rendering process needs to be deterministic, we will also be ## Component Lifecycle Hooks -Since there are no dynamic updates, of all the lifecycle hooks, only `beforeCreate` and `created` will be called during SSR. This means any code inside other lifecycle hooks such as `beforeMount` or `mounted` will only be executed on the client. +Since there are no dynamic updates, of all the lifecycle hooks, only `beforeCreate`, `created` and `serverPrefetch` will be called during SSR. This means any code inside other lifecycle hooks such as `beforeMount` or `mounted` will only be executed on the client. Another thing to note is that you should avoid code that produces global side effects in `beforeCreate` and `created`, for example setting up timers with `setInterval`. In client-side only code we may setup a timer and then tear it down in `beforeDestroy` or `destroyed`. However, because the destroy hooks will not be called during SSR, the timers will stay around forever. To avoid this, move your side-effect code into `beforeMount` or `mounted` instead.