import React from "react"; import { usePagination } from "react-use-pagination"; import drivers from "../../static/drivers.json"; import { useFilteredObjs } from "../libs/store"; import Card from "./Card"; import Paginate from "./Paginate"; export default function Driver(): JSX.Element { const { filter, setFilter, filteredObjs: filteredDrivers, } = useFilteredObjs(drivers); const props = usePagination({ totalItems: filteredDrivers.length, initialPageSize: 10, }); const { startIndex, endIndex } = props; const currentDrivers = filteredDrivers.slice(startIndex, endIndex + 1); return ( <>
setFilter(event.target.value)} />
{currentDrivers.map((driver, index) => ( ))}
); }