Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FEATURE] Propagate PresenceContext Across Nested AnimatePresence #2848

Open
custardcream98 opened this issue Oct 27, 2024 · 1 comment
Open
Labels
feature New feature or request

Comments

@custardcream98
Copy link
Contributor

custardcream98 commented Oct 27, 2024

Is your feature request related to a problem? Please describe.

When there are multiple layers of AnimatePresence, usePresence references the context of the nearest parent PresenceContext.

Because of this, even when the parent component unmounts and isPresent should be false, the isPresent of the child context remains true, 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)

@custardcream98 custardcream98 added the feature New feature or request label Oct 27, 2024
@custardcream98 custardcream98 changed the title [FEATURE] usePresence inside nested AnimatePresence [FEATURE] Propagate PresenceContext Across Nested AnimatePresence Oct 27, 2024
@custardcream98
Copy link
Contributor Author

This behavior might be considered a bug, but I'm not sure.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant