Skip to content

Commit

Permalink
Merge pull request #1312 from framer/fix/remove-context-memoisation
Browse files Browse the repository at this point in the history
Removing memoisation from context
  • Loading branch information
mergetron[bot] committed Oct 29, 2021
2 parents 877a555 + e48a15c commit b040f98
Show file tree
Hide file tree
Showing 6 changed files with 740 additions and 714 deletions.
8 changes: 7 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,13 @@

Framer Motion adheres to [Semantic Versioning](http://semver.org/).

## [5.0.0] 2021-10-25
## [5.0.1] 2021-10-29

### Fixed

- Removing context memoisation to ensure removed values are correctly animated to.

## [5.0.0] 2021-10-27

### Added

Expand Down
15 changes: 2 additions & 13 deletions src/context/MotionContext/create.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,26 +3,15 @@ import { MotionContext, MotionContextProps } from "."
import { MotionProps } from "../../motion/types"
import { getCurrentTreeVariants } from "./utils"

export function useCreateMotionContext(
props: MotionProps,
isStatic: boolean
): MotionContextProps {
export function useCreateMotionContext(props: MotionProps): MotionContextProps {
const { initial, animate } = getCurrentTreeVariants(
props,
useContext(MotionContext)
)

return useMemo(
() => ({ initial, animate }),
/**
* Only break memoisation in static mode
*/
isStatic
? [
variantLabelsAsDependency(initial),
variantLabelsAsDependency(animate),
]
: []
[variantLabelsAsDependency(initial), variantLabelsAsDependency(animate)]
)
}

Expand Down

0 comments on commit b040f98

Please sign in to comment.