Use antd's table to develop a simple multi-page page. Multi-page pagination is included in the table. This is my first time using react@15.5.4, react-router@3.0.5, antd@2.0.9, When doing routing, you can add the page number route to the browser by clicking the page number on multiple pages, but you still return to the home page after refreshing, or even though the browser address has changed, you are still on the original page number page and there is no jump. Please help. Can you do me a favor? Below is the code part
1, Route distribution
class Index extends React.Component {
render () {
return (
<Router history={hashHistory}>
<Route path="/" component={App}>
<IndexRoute component={Login}></IndexRoute>
<Route path="/finance/:page" component={Finance}></Route>
</Route>
</Router>
);
}
}
2, on the Finance page, hashHistory.push()
handleTableChange = (pagination, filters, sorter) => {
this.fetch({
results: pagination.pageSize,
page: pagination.current,
// sortField: sorter.field,
// sortOrder: sorter.order,
...filters,
});
// console.log(pagination)
hashHistory.push(`/finance/${pagination.current}`);
}
3, table component in Finance
<Table
rowSelection={rowSelection}
columns={this.columns}
rowKey={record => record.wid}
dataSource={this.state.data}
pagination={this.state.pagination}
loading={this.state.loading}
onChange={this.handleTableChange}
/>
I solved it myself. I reloaded componentWillReceiveProps. In the end, the page will change when I refresh or roll back. I don’t know if this method is correct.
Where is your setState that triggers react update?