Layout Group
Reading Time:
2
min
Released
October 2, 2023
Group motion components that should perform layout animations together.
By default, motion components with a layout prop will attempt to detect and animate layout changes every time they commit a React render.
It might be the case that components in different trees affect each other's layout.
When the state of one of these ToggleContent components changes, its sibling won't rerender, so it won't perform a layout animation.
This can be fixed by grouping both components with LayoutGroup:
Now, whenever one layout component within LayoutGroup detects and animates layout changes, they all do.
Namespace layoutId
Components expecting to perform shared layout animations are provided a layoutId prop.
layoutId is global, so if multiple instances of TabRow are rendered, only one with layoutId="underline" will render at a time.
To fix this, LayoutGroup can be provided an id prop that namespaces the layoutId for all components within it.
Istanbul
Follow us on social media