Hook within our list component.

Hook within our list component.

The usePagination hook encapsulates pagination logic. const usePagination = (items, itemsPerPage) => { const [currentPage, setCurrentPage] = React.useState(1); const maxPage = Math.ceil(items.length / itemsPerPage); const currentItems = items.slice( (currentPage -…
WithLoading HOC

WithLoading HOC

Loading behavior to any component. const withLoading = (Component) => { return function WithLoadingComponent({ isLoading, ...props }) { if (isLoading) return <p>Loading...</p>; return <Component {...props} />; }; }; Let’s apply…