Add back persisted state
This commit is contained in:
@@ -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");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
23
state.ts
23
state.ts
@@ -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);
|
||||||
|
|||||||
Reference in New Issue
Block a user