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

Create separate use_async_effect hook #1264

Merged
merged 2 commits into from
Feb 2, 2025

Conversation

Archmonger
Copy link
Contributor

@Archmonger Archmonger commented Feb 2, 2025

Description

ReactPy is made to mimick ReactJS as close to 1:1 as possible.

However, despite this we have support for async effects. Additionally, async effects bring their own technical challenges, especially related to effect cancellation.

This PR forces use_effect to only exist for synchronous functions, and creates a separate use_async_effect function. This allows use_effect to better align with the ReactJS equivalent, and subsequently allow use_async_effect to accept additional arguments that deviate from ReactJS. For example, in the future we may add a timeout value to use_effect.

Tangentially related issues:

Follow-up PR:

Checklist

Please update this checklist as you complete each item:

  • Tests have been developed for bug fixes or new functionality.
  • The changelog has been updated, if necessary.
  • Documentation has been updated, if necessary.
  • GitHub Issues closed by this PR have been linked.

By submitting this pull request I agree that all contributions comply with this project's open source license(s).

@Archmonger Archmonger changed the base branch from main to develop February 2, 2025 08:23
@Archmonger Archmonger marked this pull request as ready for review February 2, 2025 08:43
@Archmonger Archmonger merged commit 6de65ef into reactive-python:develop Feb 2, 2025
17 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant