Skip to content

Create use_effect condition that triggers every render, but only cleans up on a true unmount. #1197

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

Closed
Archmonger opened this issue Feb 19, 2024 · 1 comment
Labels
priority-2-moderate Should be resolved on a reasonable timeline.

Comments

@Archmonger
Copy link
Contributor

Archmonger commented Feb 19, 2024

Current Situation

Right now use_effect(..., dependencies=None) triggers AND cleans up on every render. But there are circumstances where I need some conditions checked (such as within ReactPy Django's django_css component) on every render, and then need a specific action taken only when a true component dismount takes place.

Proposed Actions

Create a variant of use_effect(..., dependencies=None) that can only clean up on the final render.

We might want to use this as a pivot point to change the way we currently declare "manual effect conditions". The API is currently not very intuitive.

Perhaps we have some kind of object that signifies all the available manual effect conditions?

use_effect(..., dependencies=EffectType.trigger_always_clean_always)
use_effect(..., dependencies=EffectType.trigger_always_clean_once)
use_effect(..., dependencies=EffectType.trigger_once_clean_once)
use_effect(..., dependencies=[x, y])  # Manual condition definitions
@Archmonger
Copy link
Contributor Author

Closing since this would cause a feature parity mismatch with ReactJS

@Archmonger Archmonger closed this as not planned Won't fix, can't repro, duplicate, stale Feb 2, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
priority-2-moderate Should be resolved on a reasonable timeline.
Projects
None yet
Development

No branches or pull requests

1 participant