From 184499e5e5cc5bdc9c9608f97c8be667748192c5 Mon Sep 17 00:00:00 2001 From: letuankiet212 Date: Sun, 25 Sep 2022 10:35:40 +0700 Subject: [PATCH] [RTT-02] commonFunction/ Get and set localstorage --- src/utils/function-common.tsx | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 src/utils/function-common.tsx diff --git a/src/utils/function-common.tsx b/src/utils/function-common.tsx new file mode 100644 index 0000000..c263afd --- /dev/null +++ b/src/utils/function-common.tsx @@ -0,0 +1,7 @@ +export function setLocalStorage(name: string, listData: Array) { + localStorage.setItem(name, JSON.stringify(listData)); +} + +export const getLocalStorage = (name: string) => { + return JSON.parse(localStorage.getItem(name) as string); +};