fix: JSON parsing fix
This commit is contained in:
@@ -117,19 +117,21 @@ export default function Search({ locations }: SearchProps) {
|
|||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const searchData =
|
const searchData =
|
||||||
typeof window !== "undefined"
|
typeof window !== "undefined"
|
||||||
? JSON.parse(sessionStorage.getItem(sessionStorageKey) || "")
|
? sessionStorage.getItem(sessionStorageKey)
|
||||||
: undefined
|
: undefined
|
||||||
const searchHistory =
|
const searchHistory =
|
||||||
typeof window !== "undefined"
|
typeof window !== "undefined"
|
||||||
? JSON.parse(localStorage.getItem(localStorageKey) || "")
|
? localStorage.getItem(localStorageKey)
|
||||||
: null
|
: null
|
||||||
dispatch({
|
if (searchData || searchHistory) {
|
||||||
payload: {
|
dispatch({
|
||||||
searchData,
|
payload: {
|
||||||
searchHistory,
|
searchData: searchData ? JSON.parse(searchData) : undefined,
|
||||||
},
|
searchHistory: searchHistory ? JSON.parse(searchHistory) : null,
|
||||||
type: ActionType.SET_STORAGE_DATA,
|
},
|
||||||
})
|
type: ActionType.SET_STORAGE_DATA,
|
||||||
|
})
|
||||||
|
}
|
||||||
}, [dispatch])
|
}, [dispatch])
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
Reference in New Issue
Block a user