aboutsummaryrefslogtreecommitdiff
path: root/modern/src/common/util/usePersistedState.js
diff options
context:
space:
mode:
authorAnton Tananaev <anton@traccar.org>2022-06-04 09:13:49 -0700
committerAnton Tananaev <anton@traccar.org>2022-06-04 09:13:49 -0700
commit71c5dfe153705bc6ee1931920f7713e73284115f (patch)
tree1ac2e3d9e4c383f210cc62d9d92f83b7e0b363df /modern/src/common/util/usePersistedState.js
parent022718d7d0831c246bbe01cc2d8fb66709be3189 (diff)
downloadtrackermap-web-71c5dfe153705bc6ee1931920f7713e73284115f.tar.gz
trackermap-web-71c5dfe153705bc6ee1931920f7713e73284115f.tar.bz2
trackermap-web-71c5dfe153705bc6ee1931920f7713e73284115f.zip
Filtering and sorting (fix #952)
Diffstat (limited to 'modern/src/common/util/usePersistedState.js')
-rw-r--r--modern/src/common/util/usePersistedState.js6
1 files changed, 5 insertions, 1 deletions
diff --git a/modern/src/common/util/usePersistedState.js b/modern/src/common/util/usePersistedState.js
index 8bc4401f..70a652ad 100644
--- a/modern/src/common/util/usePersistedState.js
+++ b/modern/src/common/util/usePersistedState.js
@@ -11,7 +11,11 @@ export default (key, defaultValue) => {
});
useEffect(() => {
- savePersistedState(key, value);
+ if (value !== defaultValue) {
+ savePersistedState(key, value);
+ } else {
+ window.localStorage.removeItem(key);
+ }
}, [key, value]);
return [value, setValue];