From fe072f5ddda35f5c4be91245539247af66784a1b Mon Sep 17 00:00:00 2001 From: La macchina desiderante Date: Sat, 11 May 2024 14:15:41 +0200 Subject: [PATCH] fix redux-persist server-side error msg --- package-lock.json | 4 ++-- src/store/store.ts | 19 ++++++++++++++++++- 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/package-lock.json b/package-lock.json index 4e527c8..81a0845 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "proxyraye-next", - "version": "0.1.0", + "version": "0.2.0", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "proxyraye-next", - "version": "0.1.0", + "version": "0.2.0", "dependencies": { "@picocss/pico": "^2.0.6", "@reduxjs/toolkit": "^2.2.3", diff --git a/src/store/store.ts b/src/store/store.ts index 1d6befc..fd9804c 100644 --- a/src/store/store.ts +++ b/src/store/store.ts @@ -4,7 +4,24 @@ import { useDispatch, TypedUseSelectorHook, useSelector } from "react-redux"; import { settingsReducer } from "@/store/settingsSlice"; import { persistReducer } from "redux-persist"; -import storage from "redux-persist/lib/storage"; + +import createWebStorage from "redux-persist/lib/storage/createWebStorage"; + +const createNoopStorage = () => { + return { + getItem(_key: any) { + return Promise.resolve(null); + }, + setItem(_key: any, value: any) { + return Promise.resolve(value); + }, + removeItem(_key: any) { + return Promise.resolve(); + }, + }; +}; + +const storage = typeof window !== "undefined" ? createWebStorage("local") : createNoopStorage(); const settingsPersistConfig = { key: "settings",