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) {
|
||||
|
||||
if (req.nextUrl.pathname === "/") {
|
||||
console.log('kissa', ev);
|
||||
return Response.redirect("/develop");
|
||||
|
||||
}
|
||||
|
||||
23
state.ts
23
state.ts
@@ -40,17 +40,18 @@ let initialState = {
|
||||
}
|
||||
}
|
||||
|
||||
// if (typeof window !== 'undefined') {
|
||||
// try {
|
||||
// localStorageState = localStorage.getItem('hooksIdeState');
|
||||
// } catch (err) {
|
||||
// console.log(`localStorage state broken`);
|
||||
// localStorage.removeItem('hooksIdeState');
|
||||
// }
|
||||
// }
|
||||
// if (localStorageState) {
|
||||
// initialState = JSON.parse(localStorageState);
|
||||
// }
|
||||
// Check if there's a persited state in localStorage
|
||||
if (typeof window !== 'undefined') {
|
||||
try {
|
||||
localStorageState = localStorage.getItem('hooksIdeState');
|
||||
} catch (err) {
|
||||
console.log(`localStorage state broken`);
|
||||
localStorage.removeItem('hooksIdeState');
|
||||
}
|
||||
}
|
||||
if (localStorageState) {
|
||||
initialState = JSON.parse(localStorageState);
|
||||
}
|
||||
|
||||
// Initialize state
|
||||
export const state = proxy<IState>(initialState);
|
||||
|
||||
Reference in New Issue
Block a user