CEC-2152 Add persistent page size for tables (#175)

* Add persistent page size

* Add permissions for sms as well

Co-authored-by: jwu-fisker <jwu@fiskerinc.com>
This commit is contained in:
arpanetus
2022-08-05 17:03:38 +06:00
committed by GitHub
parent 93926d3c01
commit 260a8033bb
15 changed files with 109 additions and 14 deletions

View File

@@ -0,0 +1,21 @@
import { useState, useEffect } from "react";
export function getStorageValue(key, defaultValue) {
// getting stored value
const saved = localStorage.getItem(key);
const initial = JSON.parse(saved);
return initial || defaultValue;
}
export const useLocalStorage = (key, defaultValue) => {
const [value, setValue] = useState(() => {
return getStorageValue(key, defaultValue);
});
useEffect(() => {
// storing input name
localStorage.setItem(key, JSON.stringify(value));
}, [key, value]);
return [value, setValue];
};