UNPKG

framer-motion

Version:

An open source and production-ready motion library for React on the web

66 lines (65 loc) • 1.87 kB
import * as React from "react"; import { AnimatePresenceProps } from "./types"; /** * `AnimatePresence` enables the animation of components that have been removed from the tree. * * When adding/removing more than a single child, every child **must** be given a unique `key` prop. * * @library * * Any `Frame` components that have an `exit` property defined will animate out when removed from * the tree. * * ```jsx * import { Frame, AnimatePresence } from 'framer' * * // As items are added and removed from `items` * export function Items({ items }) { * return ( * <AnimatePresence> * {items.map(item => ( * <Frame * key={item.id} * initial={{ opacity: 0 }} * animate={{ opacity: 1 }} * exit={{ opacity: 0 }} * /> * ))} * </AnimatePresence> * ) * } * ``` * * You can sequence exit animations throughout a tree using variants. * * @motion * * Any `motion` components that have an `exit` property defined will animate out when removed from * the tree. * * ```jsx * import { motion, AnimatePresence } from 'framer-motion' * * export const Items = ({ items }) => ( * <AnimatePresence> * {items.map(item => ( * <motion.div * key={item.id} * initial={{ opacity: 0 }} * animate={{ opacity: 1 }} * exit={{ opacity: 0 }} * /> * ))} * </AnimatePresence> * ) * ``` * * You can sequence exit animations throughout a tree using variants. * * If a child contains multiple `motion` components with `exit` props, it will only unmount the child * once all `motion` components have finished animating out. Likewise, any components using * `usePresence` all need to call `safeToRemove`. * * @public */ export declare const AnimatePresence: React.FunctionComponent<AnimatePresenceProps>;