-
Notifications
You must be signed in to change notification settings - Fork 121
Description
Motion provides a nice abstraction to handle animations when an item is added and removed through its AnimatePresence component. The requirement for this component to work is that it must directly wrap the component that is added or removed, i.e. it needs to be a constant, while its children are shown/hidden:
<AnimatePresence>
isActive && <Example />
</AnimatePresence>Unfortunately at the moment, wrapping the content will not not work, because the content is shown or hidden as needed, meaning <AnimatePresence> is also added and removed.
// Doesn't work
<Popover
content={() => {
return (
<AnimatePresence>
<motion.div … />
</AnimatePresence>
)
}
…
/>To solve this, react-tiny-popover could expose a way to add a wrapper component that is permanently present, and into which content is added or removed.
It's a pretty popular library and getting more popular day by day, so this would be a useful feature to add, as I don't think there is a workaround at the moment. AnimatePresence does a great job of abstracting away the hassle with animating an element that is removed from the DOM and I'm sure other libraries will follow its approach.