[questions][fix] searchParam loading from localStorage (#439)

pull/440/head
Jeff Sieu 2 years ago committed by GitHub
parent 87354c6dea
commit 4b835db8a2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -42,8 +42,12 @@ export const useSearchParam = <Value = string>(
// Try to load from local storage
const localStorageValue = localStorage.getItem(name);
if (localStorageValue !== null) {
const loadedFilters = JSON.parse(localStorageValue);
setParams(loadedFilters);
const loadedFilters = JSON.parse(localStorageValue) as Array<string>;
setParams(
loadedFilters
.map(stringToParam)
.filter((value) => value !== null) as Array<Value>,
);
}
}
setIsInitialized(true);

Loading…
Cancel
Save