Skip to content

Commit

Permalink
Merge pull request #2473 from framer/fix/null-check
Browse files Browse the repository at this point in the history
Adding null check for useAnimationControls
  • Loading branch information
mergetron[bot] committed Jan 5, 2024
2 parents bfa3957 + 1daaa37 commit e537dd9
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 2 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
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 e537dd9

Please sign in to comment.