display Number of page in React Js using material-ui Pagination

Viewed 44

look at the code below in my App.js Component:

const App = () => {
  const [workstations, setWorkstations] = useState([]);
  let [page, setPage] = useState(1);
  const PER_PAGE = 1;

 useEffect(() => {
    loadWorkstations();
  }, []);

  const loadWorkstations = async () => {
    const request = await getWorkstations();
    const result = request.data;
    setWorkstations(result);
  };

 const count = Math.ceil(workstations.length / PER_PAGE);
  const _DATA = usePagination(workstations, PER_PAGE);

  const handleChange = (e, p) => {
    setPage(p);
    _DATA.jump(p);
  };

return (
 <Pagination
          count={count}
          size="large"
          page={page}
          variant="outlined"
          color="primary"
          onChange={handleChange}
        />
);
};

now the result that i got form this implementation is like this :

enter image description here

but what im looking for should be look like this : enter image description here

i mean i don't want to see all my pages on the UI and show the rest with "..."

Note: im using @material-ui/lab

1 Answers

Your code seems alright, however, you need to import Pagination from @mui to achieve the desired behavior

import Pagination from '@mui/material/Pagination';
Related