Add back persisted state

This commit is contained in:
Valtteri Karesto
2021-11-19 16:27:48 +02:00
parent d79d013238
commit 19741add40
2 changed files with 12 additions and 12 deletions

View File

@@ -5,7 +5,6 @@ import { getToken } from "next-auth/jwt"
export default function middleware(req: NextRequest, ev: NextFetchEvent) { export default function middleware(req: NextRequest, ev: NextFetchEvent) {
if (req.nextUrl.pathname === "/") { if (req.nextUrl.pathname === "/") {
console.log('kissa', ev);
return Response.redirect("/develop"); return Response.redirect("/develop");
} }

View File

@@ -40,17 +40,18 @@ let initialState = {
} }
} }
// if (typeof window !== 'undefined') { // Check if there's a persited state in localStorage
// try { if (typeof window !== 'undefined') {
// localStorageState = localStorage.getItem('hooksIdeState'); try {
// } catch (err) { localStorageState = localStorage.getItem('hooksIdeState');
// console.log(`localStorage state broken`); } catch (err) {
// localStorage.removeItem('hooksIdeState'); console.log(`localStorage state broken`);
// } localStorage.removeItem('hooksIdeState');
// } }
// if (localStorageState) { }
// initialState = JSON.parse(localStorageState); if (localStorageState) {
// } initialState = JSON.parse(localStorageState);
}
// Initialize state // Initialize state
export const state = proxy<IState>(initialState); export const state = proxy<IState>(initialState);