Function usePagination

  • Preact hook that import pagination state to the component.

    Should always be at the top of the component!

    Parameters

    • Optionaloptions: { width?: number }

    Returns {
        current?: Page;
        first?: Page;
        last?: Page;
        next?: Page;
        pages: Page[];
        prev?: Page;
        resultsFrom: number;
        resultsTo: number;
        totalPages: number;
    }

    import { usePagination } from '@nosto/preact'

    export default () => {
    const { pages } = usePagination()

    return pages.map((page) => <li>
    {page.current ? <span>{page.page}</span> : <a>
    {page.page}
    </a>}
    </li>)
    }