@lynxts/core • Docs
@lynxts/core / UseArrayField
The result of the useArrayField hook.
• V
the type of the array value
append: (
item
) =>void
Appends a new item to the end of the array.
• item: Partial
<V
>
the item to append
void
clear: () =>
void
Clears the array by setting it's value to undefined
.
void
handle: <
F
>(action
, ...args
) => () =>void
• F extends (...args
) => void
• action: F
the action to make the handle of
• ...args: Parameters
<F
>
the parameters of the action
Function
a handle function that runs the action with the given parameters
void
insert: (
item
,at
) =>void
Insert a new item at an specific index of the array. To encourage type safety, this function follows these rules upon index outbounds:
- If the index is greater than the array size, the item is added to the end of the array.
- A negative index is treated as an offset, so -2 refers to the second to last element of the array.
• item: Partial
<V
>
the item to insert
• at: number
the index to insert the item at
void
items:
Partial
<V
>[]
The currret items Partial<V>[]
of the array. These values are partial
because they might not be present or changed by the user yet.
keygen: <
S
>(index
,key
?) =>string
• S extends object
• index: number
the current index of the array
• key?: string
| S
the preferred key value to use
string
a key value to use on React.js key
prop
prepend: (
item
) =>void
Prepends a new item to the start of the array.
• item: Partial
<V
>
the item to prepend
void
remove: (
at
) =>void
Removes the item at the specified index.
• at: number
the index of the item
void
replace: (
item
,at
) =>void
Replaces an item at an specific index of the array with another. To encourage type safety, this function follows these rules upon index outbounds:
- If the index is greater than the array size, the item is added to the end of the array.
- A negative index is treated as an offset, so -2 refers to the second to last element of the array.
• item: Partial
<V
>
the item to replace another
• at: number
the index that should be replaced
void