S
S
sharkdest2019-01-10 17:02:17
JavaScript
sharkdest, 2019-01-10 17:02:17

How to properly write table column data to localStorage (react-table)?

Hello, it was difficult to explain the essence of the issue briefly, I'll try to do it normally now.
I'm using a react-table and I want the user to be able to change the column layout. Since there is nothing of the kind in the documentation, I started searching on the Internet and found what I needed:
https://codesandbox.io/s/5vxlnjrw1n
But the problems did not end there, I need to make sure that for each by dragging a column, write a new configuration of columns (columns) to localStorage.
I tried this and it seems like everything should work fine, but dragging columns stopped working correctly.
Here's what I did: I
commented out the changes (DraggableTable.js file)
https://codesandbox.io/s/88o1j5m51j
What did I do wrong? Thank you very much in advance.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
0
0xD34F, 2019-01-11
@sharkdest

I don't see any reading of data from localStorage anywhere. Well, some obscure garbage code has also appeared, newColumns - what is it, why? In header.ondrop you save:
In the constructor you get:

this.reorder = JSON.parse(localStorage.getItem('reorder')) || [];

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question