Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import * as React from "react"
import { useId, useMemo } from "react"
import { ComponentKey } from "."
import {
PresenceContext,
PresenceContextProps,
Expand All @@ -11,11 +12,12 @@ import { PopChild } from "./PopChild"
interface PresenceChildProps {
children: React.ReactElement
isPresent: boolean
onExitComplete?: () => void
onExitComplete?: (key: ComponentKey) => void
initial?: false | VariantLabels
custom?: any
presenceAffectsLayout: boolean
mode: "sync" | "popLayout" | "wait"
childKey: ComponentKey
}

export const PresenceChild = ({
Expand All @@ -26,6 +28,7 @@ export const PresenceChild = ({
custom,
presenceAffectsLayout,
mode,
childKey,
}: PresenceChildProps) => {
const presenceChildren = useConstant(newChildrenMap)
const id = useId()
Expand All @@ -43,7 +46,7 @@ export const PresenceChild = ({
if (!isComplete) return // can stop searching when any is incomplete
}

onExitComplete?.()
onExitComplete?.(childKey)
},
register: (childId: string) => {
presenceChildren.set(childId, false)
Expand All @@ -67,7 +70,7 @@ export const PresenceChild = ({
* component immediately.
*/
React.useEffect(() => {
!isPresent && !presenceChildren.size && onExitComplete?.()
!isPresent && !presenceChildren.size && onExitComplete?.(childKey)
}, [isPresent])

if (mode === "popLayout") {
Expand Down
Loading