mirror of
https://github.com/yangshun/tech-interview-handbook.git
synced 2025-07-30 21:53:28 +08:00
[questions][fix] searchParam loading from localStorage (#439)
This commit is contained in:
@ -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);
|
||||
|
Reference in New Issue
Block a user