diff --git a/CHANGELOG.md b/CHANGELOG.md index c9224d0d0c..68f77d99e6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,12 @@ Framer Motion adheres to [Semantic Versioning](http://semver.org/). Undocumented APIs should be considered internal and may change without warning. +## [10.17.8] 2024-02-05 + +### Fixed + +- Adding `null` safeguard for `useAnimationControls`. + ## [10.17.7] 2024-02-05 ### Fixed 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)