column widths save to local storage
This commit is contained in:
parent
f328c4036a
commit
43b519ca37
1 changed files with 9 additions and 1 deletions
|
|
@ -151,7 +151,15 @@ export default function ResponsiveTable<T extends Object>(props: Props<T>) {
|
|||
const [handler, setHandler] = useState<NodeJS.Timeout | undefined>(undefined);
|
||||
const [columnAnchor, setColumnAnchor] = useState<any>(null)
|
||||
|
||||
const [rowWidths, setRowWidths] = useState<number[]>([])
|
||||
const rowKey = window.location.pathname.split('/').pop() + "-table-row-widths";
|
||||
const [rowWidths, setRowWidths] = useState<number[]>(() => {
|
||||
const saved = localStorage.getItem(rowKey);
|
||||
return saved ? JSON.parse(saved) : [];
|
||||
})
|
||||
useEffect(() => {
|
||||
localStorage.setItem(rowKey, JSON.stringify(rowWidths));
|
||||
}, [rowWidths])
|
||||
|
||||
const dragIndexRef = useRef<number | undefined>(undefined);
|
||||
const dragStartRef = useRef<number | undefined>(undefined);
|
||||
const rowWidthsRef = useRef<number[]>([]);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue