import * as React from 'react'; import {Pagination} from '@shopify/hydrogen'; /** * encapsulates the previous and next pagination behaviors throughout your application. */ export function PaginatedResourceSection({ connection, children, ariaLabel, resourcesClassName, }: { connection: React.ComponentProps>['connection']; children: React.FunctionComponent<{node: NodesType; index: number}>; ariaLabel?: string; resourcesClassName?: string; }) { return ( {({nodes, isLoading, PreviousLink, NextLink}) => { const resourcesMarkup = nodes.map((node, index) => children({node, index}), ); return (
{isLoading ? ( 'Loading...' ) : ( Load previous )} {resourcesClassName ? (
{resourcesMarkup}
) : ( resourcesMarkup )} {isLoading ? ( 'Loading...' ) : ( Load more )}
); }}
); }