From d76b02c1c5f9c2faa60bd7729c89b59eea3fdaa4 Mon Sep 17 00:00:00 2001 From: Eduardo San Martin Morote Date: Sun, 31 Mar 2024 09:36:14 +0200 Subject: [PATCH] fix(ssr): run animate on client only Close #328 --- src/useSpring.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/useSpring.ts b/src/useSpring.ts index 24ed0f2..fa69951 100644 --- a/src/useSpring.ts +++ b/src/useSpring.ts @@ -11,7 +11,7 @@ import { onScopeDispose, } from 'vue-demi' import { SpringConfig, noWobble } from './presets' -import { raf, cancelRaf, now, isArray, stepper } from './utils' +import { raf, cancelRaf, now, isArray, stepper, isClient } from './utils' const msPerFrame = 1000 / 60 @@ -97,8 +97,8 @@ export function useSpring>( let idealValues = current[0] let idealVelocities = current[1] - // only run this code on client - if (typeof window === 'undefined') { + // No need to compute or animate if we're not in the client + if (isClient) { prevTime = now() accumulatedTime = 0