2

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>
Jai Saravanan
  • 413
  • 4
  • 12
sooraj s pillai
  • 866
  • 2
  • 17
  • 39

1 Answers1

2

Maybe you can try DataTable from react-data-table-component instead. Working sample: https://codesandbox.io/embed/react-data-table-sandbox-ccyuu

Viet
  • 12,133
  • 2
  • 15
  • 21
  • It appears the project you referenced has issues with React Native. From the author: "Furthermore, while RDT is responsive enough for web layouts on modern mobile devices it is by no means a mobile library. It would be cool to develop one though if I had the time/need or if someone wanted to contribute." – FabricioG Feb 22 '22 at 06:04