0

I'm new in react and antd and I've got a problem. When I'm in some page of my table, after page refresh, I'm again in the default page number in table but I want to be in the same page I've been before refresh.

I've got similar problem when I'm trying to edit some data or add new in the table. After data save I'm again in the first page of table, but I want to be in page I've been before add/edit. Do You know how can I solve this?

Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129

1 Answers1

2

There are several ways of looking ta it. One, you could control the navigation in your table with React state, and hold the state of the table in a top level component that houses the routes (using React-Router for push-state routing, for example), or you could render changes to your table with only React and no routing changes.

You could also hold the state of the table in Redux (similar to holding state in React but instead using the global data store Redux supplies) and use a middleware like what is suggested in this post: How can I persist redux state tree on refresh?

I think nesting the state with a higher level component or a Redux Data store are your best options, as long as your careful not to rerender the entire app on every change.

Also, you could use the platform APIs, such as LocalStorage to enable client-side persistence.

Finally, you could store the data on the server everytime something changes. However, this will probably be the least performant of the available options.

ardev
  • 653
  • 2
  • 6
  • 19