Pagination in react native datatable

Viewed 2226

I'm very much new to react native currently i'm building small app for just getting an proper idea about this. I'm facing an issue in pagination i'm using react-native-paper as the ui library. So i used the inbuilt datatable from that. I've assigned 3 records to show per page but all the records are displaying in the table . Any more code to be added to this for working the pagination.

import { DataTable } from 'react-native-paper'
      const itemsPerPage = 3;
      const [page, setPage] = useState(0);
      const from = page * itemsPerPage;
      const to = (page + 1) * itemsPerPage;
    
       <DataTable.Pagination
            page={page}
            numberOfPages={Math.floor(listdata.length / itemsPerPage)}
            onPageChange={page => setPage(page)}
            label={`${from + 1}-${to} of ${listdata.length}`}
          />
       </DataTable>
1 Answers
Related