Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

use_async_effect cleanup not executed in 2.0.0b7 #1326

Answered by Archmonger
masipcat asked this question in Problem
Discussion options

Hello,

First of all, thank you for this project. I’ve been using ReactPy 2.0 in a couple of small pet projects, and it’s been really nice to work with so far.

As I mentioned in the title, the cleanup function is not executed when the dependency of the use_async_effect changes. The issue can be reproduced by transforming the test_memoized_effect_cleanup_only_triggered_before_new_effect to use an async effect:

diff --git a/tests/test_core/test_hooks.py b/tests/test_core/test_hooks.py
index 93e64a69..434d7ad3 100644
--- a/tests/test_core/test_hooks.py
+++ b/tests/test_core/test_hooks.py
@@ -451,8 +451,8 @@ async def test_memoized_effect_cleanup_only_triggered_before_new_effect():
 def ComponentWithEffect():
 state, set_state_callback.current = reactpy.hooks.use_state(first_value)
 
- @reactpy.hooks.use_effect(dependencies=[state])
- def effect():
+ @reactpy.hooks.use_async_effect(dependencies=[state])
+ async def effect():
 def cleanup():
 cleanup_trigger_count.current += 1
 

Thank you in advance

You must be logged in to vote

Replies: 1 comment 2 replies

Comment options

Thank you for the bug report. I will investigate this ASAP.

You must be logged in to vote
2 replies
Comment options

Fixed in #1328

Answer selected by Archmonger
Comment options

Thank for the fast fix!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet

AltStyle によって変換されたページ (->オリジナル) /