With a specific configuration of 3D and 2D elements, re-rendering a DOM element with layout throws the error Cannot set properties of undefined (setting 'transform').
3. IMPORTANT: Provide a CodeSandbox reproduction of the bug
a motion.group with a non-zero motionValue passed to it
another 3D motion element
A DOM motion element with layout set
The DOM motion element needs to be re-rendered
From what I can tell, the 3D motion element (<motion.group>) is creating an HTMLProjectionNode for some reason. So when this line is called on the re-render:
1. Read the FAQs 👇
✅
2. Describe the bug
With a specific configuration of 3D and 2D elements, re-rendering a DOM element with
layout
throws the errorCannot set properties of undefined (setting 'transform')
.3. IMPORTANT: Provide a CodeSandbox reproduction of the bug
https://codesandbox.io/s/prod-water-6gy983?file=/src/App.tsx
@jaredkhan did all the hard work on making this repro <3
Stack trace:
4. Steps to reproduce
Steps to reproduce the behavior:
5. Expected behavior
The red box should animate from one side to the other.
Explanation
This code reproduces the error:
Here is the magical set of requirements:
motion.group
with a non-zeromotionValue
passed to itlayout
setFrom what I can tell, the 3D motion element (
<motion.group>
) is creating an HTMLProjectionNode for some reason. So when this line is called on the re-render:https://github.com/framer/motion/blob/cebd3c3b7fcf404b3733bbea49ec35bdd6f0b7e3/packages/framer-motion/src/projection/node/HTMLProjectionNode.ts#L24
instance
is aTHREE.Group
which does not have astyle
property and it crashes