简体   繁体   中英

Keep cache of table column in reactjs

I have table component and i can customize of table column. I can relocate and also hide/show of table column.

So how can i store user customizing of table column in client cache?

Given that I don't know what package are you using to handle "table customization", I think that you could save your "custom configuration" on the local storage using localStorage.set('user custom table configuration', JSON.stringify(configObject)) .

To retrieve it, on the componentDidMount lifecycle method, you can read it and save it in the state with localStorage.get('user custom table configuration') . Consider that:

  • it might not exist (never customized the table before), so you must be able to handle a default case;
  • it will be a string, so you need to JSON.parse it;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM