• Hook that chunks an array into smaller arrays of a specified size.

    Type Parameters

    • T

      The type of elements in the array.

    Parameters

    • raw: T[]

      The original array to be chunked.

    • chunkSize: number

      The size of each chunk.

    Returns T[][]

    • An array of smaller arrays, each containing elements from the original array.
    import { useChunked } from "@i-vresse/haddock3-ui/useChunked";
    const raw = [1, 2, 3, 4, 5, 6, 7, 8, 9];
    const chunkSize = 3;
    const chunks = useChunked(raw, chunkSize);
    // chunks = [[1, 2, 3], [4, 5, 6], [7, 8, 9]]