From 83f7102f6b5a81e2fde5a1f884da22212d155e7c Mon Sep 17 00:00:00 2001 From: Rich Harris Date: Wed, 30 Jan 2019 13:35:50 -0500 Subject: [PATCH] use nextTick --- templates/src/client/app.ts | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/templates/src/client/app.ts b/templates/src/client/app.ts index 5ec07c0..a409203 100644 --- a/templates/src/client/app.ts +++ b/templates/src/client/app.ts @@ -1,3 +1,4 @@ +import { nextTick } from 'svelte'; import RootComponent, * as RootComponentStatic from '__ROOT__'; import ErrorComponent from '__ERROR__'; import { @@ -161,10 +162,12 @@ function render(props: any, nullable_depth: number, scroll: ScrollPosition, nosc level.component = null; root_component.$set({ child: props.child }); - // then render new stuff - // TODO do we need to call `flush` before doing this? - level.component = component; - root_component.$set(props); + nextTick(() => { + // then render new stuff + // TODO do we need to call `flush` before doing this? + level.component = component; + root_component.$set(props); + }); } else { // first load — remove SSR'd contents const start = document.querySelector('#sapper-head-start');