loading code fetching the highlighted snippet
<PresenceChild present={…}> keeps the card rendered after present flips false. Inside, usePresence hands the card a safeToRemove callback — the card runs its own CSS transition and releases the wrapper on transitionend.
PresenceChild holds the child rendered while the surrounding AnimatePresence is exiting it. The card stays in the DOM with isPresent === false until safeToRemove() fires.const presence = usePresence() (called once) registers
the card with its wrapper and returns [isPresent, safeToRemove] reactively. The effect listens for transitionend on the card node and calls safeToRemove once the CSS transition completes — fully custom exit under
the component's own control.safeToRemove becomes a no-op so a late transitionend can't tear down a now-present card. onExitComplete on the parent tallies finished exits.Independent motion descendants share one owned wrapper. The fast exit finishes first; removal waits for the slow exit too.
Click Hide group. Fast finishes first; the wrapper stays mounted while Slow finishes. Both are removed together. Show during exit to cancel, or Reset to start over.
Progress follows the animated position. Completion states come from animation callbacks; the mounted state follows the actual wrapper.