Skip to content

Commit 11b0af3

Browse files
committed
changelog entry
1 parent 365227d commit 11b0af3

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

docs/source/about/changelog.rst

+22
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,28 @@ Unreleased
4141
``idom-router``, IDOM's server routes will always take priority.
4242
- :pull:`824` - Backend implementations now strip any URL prefix in the pathname for
4343
``use_location``.
44+
- :pull:`827` - ``use_state`` now returns a named tuple with ``value`` and ``set_value``
45+
fields. This is convenient for adding type annotations if the initial state value is
46+
not the same as the values you might pass to the state setter. Where previously you
47+
might have to do something like:
48+
49+
.. code-block::
50+
51+
value: int | None = None
52+
value, set_value = use_state(value)
53+
54+
Now you can annotate your state using the ``State`` class:
55+
56+
.. code-block::
57+
58+
state: State[int | None] = use_state(None)
59+
60+
# access value and setter
61+
state.value
62+
state.set_value
63+
64+
# can still destructure if you need to
65+
value, set_value = state
4466
4567
**Added**
4668

0 commit comments

Comments
 (0)