Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/reactjs/23.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/react-native/7.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Reactjs react本机数据表中的分页_Reactjs_React Native - Fatal编程技术网

Reactjs react本机数据表中的分页

Reactjs react本机数据表中的分页,reactjs,react-native,Reactjs,React Native,我对react native非常陌生,目前我正在构建一个小应用程序,以便对此有一个正确的想法。我在分页时遇到了一个问题,我正在使用react native paper作为ui库。所以我使用了它的内置数据表。我为每页分配了3条记录,但所有记录都显示在表中。要添加到此中以进行分页的任何其他代码 import { DataTable } from 'react-native-paper' const itemsPerPage = 3; const [page, setPage]

我对react native非常陌生,目前我正在构建一个小应用程序,以便对此有一个正确的想法。我在分页时遇到了一个问题,我正在使用react native paper作为ui库。所以我使用了它的内置数据表。我为每页分配了3条记录,但所有记录都显示在表中。要添加到此中以进行分页的任何其他代码

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>
从'react native paper'导入{DataTable}
const itemsPerPage=3;
const[page,setPage]=useState(0);
const from=第页*itemsPerPage;
常数至=(第+1页)*项目页面;
设置页面(第页)}
label={{listdata.length}}的{`${from+1}-${to}
/>

也许您可以从react data table组件中尝试DataTable。 工作样本: