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.usePresence() returns [isPresent, safeToRemove]. 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.