You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardexpand all lines: src/useAsyncIterState/index.ts
+9-9
Original file line number
Diff line number
Diff line change
@@ -43,14 +43,14 @@ export { useAsyncIterState, type AsyncIterStateResult, type AsyncIterableChannel
43
43
* ---
44
44
*
45
45
* The returned async iterable can be passed over to any level down the component tree and rendered
46
-
* using `<Iterate>`, `useAsyncIter`, and others. It also contains a `.current.value` property which shows
46
+
* using `<Iterate>`, `useAsyncIter`, and others. It also contains a `.value.current` property which shows
47
47
* the current up to date state value at all times. Use this any time you need to read the immediate
48
48
* current state (for example as part of side effect logic) rather than directly rendering it, since
49
49
* for rendering you may simply iterate values as part of an `<Iterate>`.
50
50
*
51
51
* Returned also alongside the async iterable is a function for updating the state. Calling it with a new
52
52
* value will cause the paired iterable to yield the updated state value as well as immediately set the
53
-
* iterable's `.current.value` property to that new state. Just like
53
+
* iterable's `.value.current` property to that new state. Just like
54
54
* [`React.useState`'s setter](https://react.dev/reference/react/useState#setstate), you can pass it
55
55
* the next state directly, or a function that calculates it from the previous state.
56
56
*
@@ -62,7 +62,7 @@ export { useAsyncIterState, type AsyncIterStateResult, type AsyncIterableChannel
62
62
*
63
63
* @example
64
64
* ```tsx
65
-
* // Use the state iterable's `.current.value` property to read the immediate current state:
65
+
* // Use the state iterable's `.value.current` property to read the immediate current state:
66
66
*
67
67
* import { useAsyncIterState } from 'react-async-iterators';
68
68
*
@@ -73,8 +73,8 @@ export { useAsyncIterState, type AsyncIterStateResult, type AsyncIterableChannel
73
73
* return (
74
74
* <form
75
75
* onSubmit={() => {
76
-
* const firstName = firstNameIter.current.value;
77
-
* const lastName = lastNameIter.current.value;
76
+
* const firstName = firstNameIter.value.current;
77
+
* const lastName = lastNameIter.value.current;
78
78
* // submit `firstName` and `lastName`...
79
79
* }}
80
80
* >
@@ -93,9 +93,9 @@ export { useAsyncIterState, type AsyncIterStateResult, type AsyncIterableChannel
93
93
* ---
94
94
*
95
95
* @template TVal the type of state to be set and yielded by returned iterable.
96
-
* @template TInitVal The type of the starting value for the state iterable's `.current.value` property.
96
+
* @template TInitVal The type of the starting value for the state iterable's `.value.current` property.
97
97
*
98
-
* @param initialValue Any optional starting value for the state iterable's `.current.value` property, defaults to `undefined`. You can pass an actual value, or a function that returns a value (which the hook will call once during mounting).
98
+
* @param initialValue Any optional starting value for the state iterable's `.value.current` property, defaults to `undefined`. You can pass an actual value, or a function that returns a value (which the hook will call once during mounting).
99
99
*
100
100
* @returns a stateful async iterable and a function with which to yield an update, both maintain stable references across re-renders.
101
101
*
@@ -146,7 +146,7 @@ type AsyncIterStateResult<TVal, TInitVal> = [
146
146
/**
147
147
* A stateful async iterable which yields every updated value following a state update.
148
148
*
149
-
* Includes a `.current.value` property which shows the current up to date state value at all times.
149
+
* Includes a `.value.current` property which shows the current up to date state value at all times.
150
150
*
151
151
* This is a shared async iterable - all iterators obtained from it share the same source values,
152
152
* meaning multiple iterators can be consumed (iterated) simultaneously, each one picking up the
@@ -156,7 +156,7 @@ type AsyncIterStateResult<TVal, TInitVal> = [
156
156
157
157
/**
158
158
* A function which updates the state, causing the paired async iterable to yield the updated state
159
-
* value and immediately sets its `.current.value` property to the latest state.
159
+
* value and immediately sets its `.value.current` property to the latest state.
0 commit comments