Skip to content

Conversation

@FeodorFitsner
Copy link
Contributor

@FeodorFitsner FeodorFitsner commented Oct 23, 2025

The use_state hook now accepts updater functions, allowing state to be set based on the previous value, similar to React's useState. Updated type hints, docstrings, and internal logic to support this feature and improve clarity.

Summary by Sourcery

Enable functional updates in the use_state hook by allowing the setter to accept updater functions or direct values, enhance related type hints and documentation, and include a new example showcasing list state updates.

New Features:

  • Allow use_state setter to accept functional updater functions based on previous state
  • Add example app demonstrating functional list updates with auto-scrolling

Enhancements:

  • Introduce StateT and Updater type hints for use_state
  • Update docstrings and type signatures to clarify setter behavior
  • Refactor subscription logic with clearer naming and comments

The use_state hook now accepts updater functions, allowing state to be set based on the previous value, similar to React's useState. Updated type hints, docstrings, and internal logic to support this feature and improve clarity.
Copy link
Contributor

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We've reviewed this pull request using the Sourcery rules engine

@cloudflare-workers-and-pages
Copy link

Deploying flet-docs with  Cloudflare Pages  Cloudflare Pages

Latest commit: ef2c5d7
Status: ✅  Deploy successful!
Preview URL: https://c29fd2f6.flet-docs.pages.dev
Branch Preview URL: https://use-state-fix.flet-docs.pages.dev

View logs

@FeodorFitsner FeodorFitsner merged commit 9453dd1 into main Oct 23, 2025
30 of 46 checks passed
@FeodorFitsner FeodorFitsner deleted the use-state-fix branch October 23, 2025 16:53
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.

2 participants