Remove localStorage support because it breaks ssr

This commit is contained in:
pikiou
2022-02-02 14:11:43 +01:00
parent b21b77e513
commit 3264336aab
5 changed files with 12 additions and 16 deletions

View File

@@ -41,10 +41,12 @@ const createStore = ({ initialState, url, jwt, id }: Arg = {}) => {
return { store, history }
}
const storage: any = localStorage
const id = +(Cookies.get("id") || storage?.getItem("id"))
const jwt = Cookies.get("jwt") || storage?.getItem("jwt")
const id = +(Cookies.get("id") || 0)
const jwt = Cookies.get("jwt")
if (id && jwt) {
Cookies.set("id", `${id}`, { expires: 3650 })
Cookies.set("jwt", jwt, { expires: 3650 })
}
const { store } = createStore({ id, jwt })
export type AppState = ReturnType<typeof store.getState>