Skip to content

Commit

Permalink
Adding null check
Browse files Browse the repository at this point in the history
  • Loading branch information
mattgperry authored and mergatron[bot] committed Jan 5, 2024
1 parent bfa3957 commit 2de3a22
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -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"
)
}
1 change: 1 addition & 0 deletions packages/framer-motion/src/utils/is-ref-object.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { MutableRefObject } from "./safe-react-types"

export function isRefObject<E = any>(ref: any): ref is MutableRefObject<E> {
return (
ref &&
typeof ref === "object" &&
Object.prototype.hasOwnProperty.call(ref, "current")
)
Expand Down
2 changes: 1 addition & 1 deletion packages/framer-motion/src/utils/transform.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export interface TransformOptions<T> {
}

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)
Expand Down

0 comments on commit 2de3a22

Please sign in to comment.