When a component is the child of AnimatePresence, it can use usePresence to access information about whether it's still present in the React tree.
AnimatePresence
usePresence
import { usePresence } from "framer-motion"export const Component = () => { const [isPresent, safeToRemove] = usePresence() useEffect(() => { !isPresent && setTimeout(safeToRemove, 1000) }, [isPresent]) return <div />} Copy
import { usePresence } from "framer-motion"export const Component = () => { const [isPresent, safeToRemove] = usePresence() useEffect(() => { !isPresent && setTimeout(safeToRemove, 1000) }, [isPresent]) return <div />}
If isPresent is false, it means that a component has been removed the tree, but AnimatePresence won't really remove it until safeToRemove has been called.
isPresent
false
safeToRemove
Generated using TypeDoc
When a component is the child of
AnimatePresence, it can useusePresenceto access information about whether it's still present in the React tree.If
isPresentisfalse, it means that a component has been removed the tree, butAnimatePresencewon't really remove it untilsafeToRemovehas been called.