Loading source
Pulling the file list, source metadata, and syntax-aware rendering for this listing.
Source from repo
Living wiki of UI design patterns and best practices built with Fumadocs, Next.js, and Base UI components.
Files
Skill
Size
Entrypoint
Format
Open file
Syntax-highlighted preview of this file as included in the skill package.
rules/presence-safe-to-remove.md
1---2title: Call safeToRemove After Async Work3impact: HIGH4tags: presence, safe-to-remove, async5---67## Call safeToRemove After Async Work89When using usePresence, always call safeToRemove after async work.1011**Incorrect (missing safeToRemove):**1213```tsx14function AsyncComponent() {15const [isPresent, safeToRemove] = usePresence();1617useEffect(() => {18if (!isPresent) {19cleanup();20}21}, [isPresent]);22}23```2425**Correct (safeToRemove called):**2627```tsx28function AsyncComponent() {29const [isPresent, safeToRemove] = usePresence();3031useEffect(() => {32if (!isPresent) {33cleanup().then(safeToRemove);34}35}, [isPresent, safeToRemove]);36}37```38