From 2de3a229b0f232c966964a28cfe4e02f315f194a Mon Sep 17 00:00:00 2001 From: Matt Perry Date: Fri, 5 Jan 2024 10:22:27 +0100 Subject: [PATCH] Adding null check --- .../src/animation/utils/is-animation-controls.ts | 6 +++++- packages/framer-motion/src/utils/is-ref-object.ts | 1 + packages/framer-motion/src/utils/transform.ts | 2 +- 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/packages/framer-motion/src/animation/utils/is-animation-controls.ts b/packages/framer-motion/src/animation/utils/is-animation-controls.ts index d715851309..fcc61b1e44 100644 --- a/packages/framer-motion/src/animation/utils/is-animation-controls.ts +++ b/packages/framer-motion/src/animation/utils/is-animation-controls.ts @@ -1,5 +1,9 @@ import { AnimationControls } from "../types" export function isAnimationControls(v?: unknown): v is AnimationControls { - return typeof v === "object" && typeof (v as any).start === "function" + return ( + v !== null && + typeof v === "object" && + typeof (v as AnimationControls).start === "function" + ) } diff --git a/packages/framer-motion/src/utils/is-ref-object.ts b/packages/framer-motion/src/utils/is-ref-object.ts index 9c253d7baf..3c0d58e84f 100644 --- a/packages/framer-motion/src/utils/is-ref-object.ts +++ b/packages/framer-motion/src/utils/is-ref-object.ts @@ -2,6 +2,7 @@ import { MutableRefObject } from "./safe-react-types" export function isRefObject(ref: any): ref is MutableRefObject { return ( + ref && typeof ref === "object" && Object.prototype.hasOwnProperty.call(ref, "current") ) diff --git a/packages/framer-motion/src/utils/transform.ts b/packages/framer-motion/src/utils/transform.ts index b0947b93a1..1d43de77a1 100644 --- a/packages/framer-motion/src/utils/transform.ts +++ b/packages/framer-motion/src/utils/transform.ts @@ -31,7 +31,7 @@ export interface TransformOptions { } const isCustomValueType = (v: any): v is CustomValueType => { - return typeof v === "object" && v.mix + return v && typeof v === "object" && v.mix } const getMixer = (v: any) => (isCustomValueType(v) ? v.mix : undefined)