diff --git a/packages/lib-classifier/src/hooks/useSessionStorage.js b/packages/lib-classifier/src/hooks/useSessionStorage.js index 7fd10db9374..e7c08944234 100644 --- a/packages/lib-classifier/src/hooks/useSessionStorage.js +++ b/packages/lib-classifier/src/hooks/useSessionStorage.js @@ -1,5 +1,5 @@ import { addDisposer, onSnapshot } from 'mobx-state-tree' -import { useEffect, useState } from 'react' +import { useState } from 'react' import { asyncSessionStorage } from '@helpers' @@ -13,8 +13,13 @@ function persist(storageKey, store, storage) { } export default function useSessionStorage(enableStorage, store, storageKey) { - if (!!store && enableStorage) { - persist(storageKey, store, asyncSessionStorage) + const [loaded, setLoaded] = useState(false) + + if (!loaded && !!store) { + if (enableStorage) { + persist(storageKey, store, asyncSessionStorage) + } + setLoaded(true) } return store } \ No newline at end of file