File tree 1 file changed +22
-0
lines changed
1 file changed +22
-0
lines changed Original file line number Diff line number Diff line change @@ -41,6 +41,28 @@ Unreleased
41
41
``idom-router ``, IDOM's server routes will always take priority.
42
42
- :pull: `824 ` - Backend implementations now strip any URL prefix in the pathname for
43
43
``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
44
66
45
67
**Added **
46
68
You can’t perform that action at this time.
0 commit comments