Skip to content

Commit f2e4fef

Browse files
authoredJan 23, 2025
docs: fix mentions of the current value property from .current.value to .value.current (#64)
1 parent c4174ee commit f2e4fef

File tree

3 files changed

+11
-11
lines changed

3 files changed

+11
-11
lines changed
 

‎spec/tests/useAsyncIterState.spec.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ describe('`useAsyncIterState` hook', () => {
2929
}
3030
);
3131

32-
it(gray("The state iterable's `.current.value` property is read-only"), async () => {
32+
it(gray("The state iterable's `..value.current` property is read-only"), async () => {
3333
const [values] = renderHook(() => useAsyncIterState<string>()).result.current;
3434

3535
expect(() => {

‎src/common/AsyncIterableChannel.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ class AsyncIterableChannel<T, TInit = T> {
5959

6060
/**
6161
* A stateful async iterable which will yield every updated value following an update. Includes a
62-
* `.current.value` property which shows the current up to date state value.
62+
* `.value.current` property which shows the current up to date state value.
6363
*
6464
* This is a shared async iterable - all iterators obtained from it share the same source values,
6565
* meaning that multiple iterators can be consumed (iterated) simultaneously and each one would pick up

‎src/useAsyncIterState/index.ts

+9-9
Original file line numberDiff line numberDiff line change
@@ -43,14 +43,14 @@ export { useAsyncIterState, type AsyncIterStateResult, type AsyncIterableChannel
4343
* ---
4444
*
4545
* 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
4747
* the current up to date state value at all times. Use this any time you need to read the immediate
4848
* current state (for example as part of side effect logic) rather than directly rendering it, since
4949
* for rendering you may simply iterate values as part of an `<Iterate>`.
5050
*
5151
* Returned also alongside the async iterable is a function for updating the state. Calling it with a new
5252
* 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
5454
* [`React.useState`'s setter](https://react.dev/reference/react/useState#setstate), you can pass it
5555
* the next state directly, or a function that calculates it from the previous state.
5656
*
@@ -62,7 +62,7 @@ export { useAsyncIterState, type AsyncIterStateResult, type AsyncIterableChannel
6262
*
6363
* @example
6464
* ```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:
6666
*
6767
* import { useAsyncIterState } from 'react-async-iterators';
6868
*
@@ -73,8 +73,8 @@ export { useAsyncIterState, type AsyncIterStateResult, type AsyncIterableChannel
7373
* return (
7474
* <form
7575
* 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;
7878
* // submit `firstName` and `lastName`...
7979
* }}
8080
* >
@@ -93,9 +93,9 @@ export { useAsyncIterState, type AsyncIterStateResult, type AsyncIterableChannel
9393
* ---
9494
*
9595
* @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.
9797
*
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).
9999
*
100100
* @returns a stateful async iterable and a function with which to yield an update, both maintain stable references across re-renders.
101101
*
@@ -146,7 +146,7 @@ type AsyncIterStateResult<TVal, TInitVal> = [
146146
/**
147147
* A stateful async iterable which yields every updated value following a state update.
148148
*
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.
150150
*
151151
* This is a shared async iterable - all iterators obtained from it share the same source values,
152152
* meaning multiple iterators can be consumed (iterated) simultaneously, each one picking up the
@@ -156,7 +156,7 @@ type AsyncIterStateResult<TVal, TInitVal> = [
156156

157157
/**
158158
* 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.
160160
*/
161161
setValue: (update: MaybeFunction<TVal, [prevState: TVal | TInitVal]>) => void,
162162
];

0 commit comments

Comments
 (0)