'Pagination in react native datatable
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>
Solution 1:[1]
Maybe you can try DataTable from react-data-table-component instead. Working sample: https://codesandbox.io/embed/react-data-table-sandbox-ccyuu
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Viet |
