Skip to content

Commit

Permalink
Fixing
Browse files Browse the repository at this point in the history
  • Loading branch information
mattgperry committed Oct 31, 2024
1 parent 1e7f9df commit c3593da
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions packages/framer-motion/src/motion/utils/use-visual-element.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,14 @@ export function useVisualElement<Instance, RenderState>(
)
}

const isMounted = useRef(false)
useInsertionEffect(() => {
if (visualElement && visualElement.current) {
visualElement && visualElement.update(props, presenceContext)
/**
* Check the component has already mounted before calling
* `update` unnecessarily. This ensures we skip the initial update.
*/
if (visualElement && isMounted.current) {
visualElement.update(props, presenceContext)
}
})

Expand All @@ -93,6 +98,7 @@ export function useVisualElement<Instance, RenderState>(
useIsomorphicLayoutEffect(() => {
if (!visualElement) return

isMounted.current = true
window.MotionIsMounted = true

visualElement.updateFeatures()
Expand Down

0 comments on commit c3593da

Please sign in to comment.