useArray
Use an array state with some common and simple array methods.
- Task #1
- Task #2
Type Definitions
import { SetStateAction } from 'react';
const useArray: <T>(initial?: T[]) => {
array: T[];
length: number;
get(index: number): T | undefined;
set(index: number, element: T): void;
has(...elements: T[]): boolean;
count(element: T): number;
push(...elements: T[]): void;
pop(index?: number): T | undefined;
shift(): T | undefined;
unshift(...elements: T[]): void;
insert(index: number, ...elements: T[]): void;
reset(value?: SetStateAction<T[]>): void;
};