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

Improve typing of use_state hook #208

Open
mofojed opened this issue Jan 17, 2024 · 0 comments
Open

Improve typing of use_state hook #208

mofojed opened this issue Jan 17, 2024 · 0 comments
Labels
enhancement New feature or request
Milestone

Comments

@mofojed
Copy link
Member

mofojed commented Jan 17, 2024

We want the typings of use_state to match the behaviour of React.useState.
In particular, if you want to define an optional number value, you should be able to define it simply as:

x, set_x = use_state[int]()
# x should be type `int | None`

This will require python 3.12, for the type parameter syntax: https://docs.python.org/3/reference/compound_stmts.html#type-params

Also see discussion about applying default values with overloads: python/mypy#3737 (comment)

@mofojed mofojed added enhancement New feature or request triage labels Jan 17, 2024
@vbabich vbabich added this to the Backlog milestone Jan 30, 2024
@vbabich vbabich removed the triage label Jan 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants