[FEATURE] Propagate PresenceContext
Across Nested AnimatePresence
#2848
Labels
feature
New feature or request
PresenceContext
Across Nested AnimatePresence
#2848
Is your feature request related to a problem? Please describe.
When there are multiple layers of
AnimatePresence
,usePresence
references the context of the nearest parentPresenceContext
.Because of this, even when the parent component unmounts and
isPresent
should be false, theisPresent
of the child context remainstrue
, making it difficult to achieve the desired behavior.Describe the solution you'd like
In cases with multiple layers, the
usePresence
value in the child should be updated based on the context of the parent's. Alternatively, there should be a way to access the parent context directly.Describe alternatives you've considered
Currently, this issue can only be resolved by defining a custom component or context that passes down the parent's isPresent value to its children.
Additional context
Checkout Codesandbox here
(Try clicking the toggle button and observe the
isPresent
values of the Parent and Children components)The text was updated successfully, but these errors were encountered: