usePresence

Holds a child of an AnimatePresence on the page as it leaves, until you let it go: for an exit of your own, such as a Web Animation or a timer. Motion's usePresence. Solid 1's alone.

import { usePresence } from "@wardic/solid/v1"

let el!: HTMLDivElement
const isPresent = usePresence(() => el, (safeToRemove, custom) => {
  el.animate({ opacity: [1, 0] }, 300).finished.then(safeToRemove)
})
<div ref={el} />

usePresence(target, onLeave): target is the child's element, or an accessor of it. onLeave(safeToRemove, custom) is called as the child leaves, with the presence's custom. It returns whether the child is present, false from its leave on.

By the time the child leaves, its own effects have ended, so what runs then is plain work on the element that's still on the page, ending with safeToRemove(). Outside a presence, the child is always present, and nothing is called.

Solid 2

What cares about leaving has a ward, one with no motion if it needs none. A ward under a presence hears its own leave: ward.exiting() is true from it, and ward.hold() keeps it on the page until the release it hands back is called.