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
feat(Iterate): support initial value in function form (#49)
* allow initial value to be a function, called once on mount
* feat: introduce `MaybeFunction` type to clean up places accepting a value-or-function types of inputs
* feat(Iterate): support initial value in function form and update type definitions
* improve TODO comments to implement corresponding behaviors for `useAsyncIterMulti` and `IterateMulti` as well
* An optional initial value, defaults to `undefined`. Will be the value provided inside the child
147
-
* render function when `<Iterate>` first renders on being mounted and while it's pending its first
148
-
* value to be yielded.
148
+
* An optional starting value, defaults to `undefined`. Will be the value inserted into the child render
149
+
* function when `<Iterate>` first renders during mount and while it's pending its first value to be
150
+
* yielded.
151
+
*
152
+
* You can pass an actual value, or a function that returns a value (which `<Iterate>` will call once during mounting).
149
153
*/
150
-
initialValue?: TInitialVal;
154
+
initialValue?: MaybeFunction<TInitialVal>;
151
155
/**
152
156
* A render function that is called for each step of the iteration, returning something to render
153
157
* out of it.
154
158
*
155
-
* @param nextIterationState - The current state of the iteration, including the yielded value, whether iteration is complete, any associated error, etc. (see {@link IterationResult `IterationResult`})
159
+
* @param nextIterationState - The current state of the iteration, including the yielded value, whether iteration is complete, any associated error, etc. (see {@link IterationResult `IterationResult`}).
156
160
* @returns The content to render for the current iteration state.
157
161
*
158
162
* @see {@link IterateProps `IterateProps`}
@@ -169,10 +173,12 @@ type IteratePropsWithNoRenderFunction = {
169
173
value?: undefined;
170
174
/**
171
175
* An optional initial value, defaults to `undefined`.
176
+
*
177
+
* You can pass an actual value, or a function that returns a value (which `<Iterate>` will call once during mounting).
172
178
*/
173
-
initialValue?: ReactNode;
179
+
initialValue?: MaybeFunction<ReactNode>;
174
180
/**
175
181
* The source value to render from, either an async iterable to iterate over of a plain value.
0 commit comments