reactjs - React Table default pagination page
问题描述
I'm new to react-table. Is it possible to set default page in the pagination mode. Is there a certain prop to handle this? F.ex. after my component mounts I'd like to have my table opened on 5th page. Thank you!
解决方案
You probably already discovered this, but to expand on hariharan's answer, you can use the state of a component to control a lot of the props of the table. For the page, you can tell the component that the page is found in the state,
<ReactTable
...otherProps
page={this.state.page}
/>
And when you initialize your state, however you initialize it, have page equal to 5. For example,
class MyClassThatHasReactTableInIt extends Component {
constructor (props) {
super(props);
this.state = {
page: 5
}
... // etc code etc
If you do this, you also need to handle the page changing yourself though. luckily, react-table makes this very easy, you can write your custom pageChange handler:
<ReactTable
...otherProps
page={this.state.page}
onPageChange={page => this.setState({page})}
/>
推荐阅读
- php - Hoare 分区方案返回错误的索引
- spring - spring框架model和view中双冒号是什么意思?
- python - 如何在 TKinter 列表框中移动选择多个项目?
- c - C libpcap API 提取 DNS 查询
- jakarta-ee - 为什么 WSO2 API Manager 有时会出错:代理错误代理服务器收到来自上游服务器的无效响应?
- javascript - JS:按下按钮n次后如何执行功能?
- docker - Docker API 构建 Tar 文件路径
- qt - 强制 qt-vlc 不隐藏鼠标光标
- ruby - 如何在配方中的控制语句中检查节点版本
- vba - 复制和重命名文件