Skip to content

Commit

Permalink
login redirect fix
Browse files Browse the repository at this point in the history
  • Loading branch information
sethwalker1 committed Jul 18, 2021
1 parent 32e734a commit cfbebed
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions pages/index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import React, { useEffect, useContext } from 'react'
import { useRouter } from 'next/router'
import { CSSTransition } from 'react-transition-group'
import todoContext from '../context/todo/todoContext'
import authContext from '../context/auth/authContext'
Expand All @@ -8,14 +9,16 @@ import { MDBContainer, MDBRow } from 'mdbreact'

const Todo = (props) => {

const router = useRouter()

const TodoContext = useContext(todoContext)
const { list, getList } = TodoContext

const AuthContext = useContext(authContext)
const { logout } = AuthContext
const token = localStorage.getItem('token')

const token = localStorage.getItem('token')
useEffect(() => {
console.log(token)
if (router.isReady && token === null)
router.push('/login')
getList(token)
Expand Down

1 comment on commit cfbebed

@vercel
Copy link

@vercel vercel bot commented on cfbebed Jul 18, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.