fix: SW-693 Fixed hydration error
This commit is contained in:
@@ -22,27 +22,14 @@ export function getSearchHistoryFromLocalStorage() {
|
||||
}
|
||||
|
||||
export const sessionStorageKey = "searchData"
|
||||
export function getSearchDataFromSessionStorage() {
|
||||
if (typeof window !== "undefined") {
|
||||
const storageSearchData = window.sessionStorage.getItem(sessionStorageKey)
|
||||
if (storageSearchData) {
|
||||
const parsedStorageSearchData: Location = JSON.parse(storageSearchData)
|
||||
if (parsedStorageSearchData) {
|
||||
return parsedStorageSearchData
|
||||
}
|
||||
}
|
||||
}
|
||||
return undefined
|
||||
}
|
||||
|
||||
export function init(initState: InitState): State {
|
||||
const searchHistory = getSearchHistoryFromLocalStorage()
|
||||
const searchData = getSearchDataFromSessionStorage()
|
||||
return {
|
||||
defaultLocations: initState.defaultLocations,
|
||||
locations: [],
|
||||
search: "",
|
||||
searchData,
|
||||
searchData: initState.searchData,
|
||||
searchHistory,
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user