Skip to content

Commit c3593da

Browse files
committed
Fixing
1 parent 1e7f9df commit c3593da

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

packages/framer-motion/src/motion/utils/use-visual-element.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,9 +72,14 @@ export function useVisualElement<Instance, RenderState>(
7272
)
7373
}
7474

75+
const isMounted = useRef(false)
7576
useInsertionEffect(() => {
76-
if (visualElement && visualElement.current) {
77-
visualElement && visualElement.update(props, presenceContext)
77+
/**
78+
* Check the component has already mounted before calling
79+
* `update` unnecessarily. This ensures we skip the initial update.
80+
*/
81+
if (visualElement && isMounted.current) {
82+
visualElement.update(props, presenceContext)
7883
}
7984
})
8085

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

101+
isMounted.current = true
96102
window.MotionIsMounted = true
97103

98104
visualElement.updateFeatures()

0 commit comments

Comments
 (0)