Skip to content

Commit

Permalink
hotfix: localStorage 확인시server render시 window 객체 여부 조건 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
hyeseon-han committed Feb 18, 2024
1 parent 32d0af3 commit c0b3839
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/components/templates/withLogin.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
import React, { useEffect } from 'react';

import { useRouter } from 'next/router';

const withLogin = (InnerComponent: React.FC) => {
return () => {
const router = useRouter();
const token = localStorage.getItem('accessToken');
const token =
typeof window !== 'undefined'
? localStorage.getItem('accessToken')
: null;

const redirectToLogin: () => Promise<void> = async () => {
if (!token) {
Expand Down

0 comments on commit c0b3839

Please sign in to comment.