From 49222debfa553f90ba6e7d27e141170d1fd2c9af Mon Sep 17 00:00:00 2001 From: Haorui Harry Zheng <98264403+zhngharry@users.noreply.github.com> Date: Mon, 17 Jun 2024 18:36:32 +0200 Subject: [PATCH] fix: tabs order from localstorage parsing (#786) --- src/app.tsx | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/app.tsx b/src/app.tsx index 4bb21862..2f0fc9f6 100644 --- a/src/app.tsx +++ b/src/app.tsx @@ -46,10 +46,9 @@ class App extends React.Component< super(props); // Get tabs config from local storage - const tabsString = getLocalStorageDataFromKey(LOCALSTORAGE_KEYS.tabs, null); + const tabsData = getLocalStorageDataFromKey(LOCALSTORAGE_KEYS.tabs, null); let tabs: TabItemConfig[] = []; try { - tabs = JSON.parse(tabsString); if (!Array.isArray(tabs)) { throw new Error("Could not parse marketplace tabs key"); } @@ -59,6 +58,8 @@ class App extends React.Component< if (tabs.filter((tab) => !tab).length > 0) { throw new Error("Falsey marketplace tabs key"); } + + tabs = tabsData; } catch { tabs = ALL_TABS; localStorage.setItem(LOCALSTORAGE_KEYS.tabs, JSON.stringify(tabs));