From 7f316e3c063594a7a2be5811ae48e656668fe7a5 Mon Sep 17 00:00:00 2001 From: lavegaa Date: Sat, 28 Nov 2020 17:26:27 +0900 Subject: [PATCH] =?UTF-8?q?feat:=20=EC=83=88=EB=A1=9C=EA=B3=A0=EC=B9=A8?= =?UTF-8?q?=EC=8B=9C=20=EB=A1=9C=EA=B7=B8=EC=9D=B8=20=EC=9C=A0=EC=A7=80=20?= =?UTF-8?q?(#66)=20=EB=A1=9C=EA=B7=B8=EC=9D=B8=20=EC=8B=9C=20=EC=9C=A0?= =?UTF-8?q?=EC=A0=80=20=EC=A0=95=EB=B3=B4=20=EC=84=B8=EC=85=98=20=EC=8A=A4?= =?UTF-8?q?=ED=86=A0=EB=A6=AC=EC=A7=80=EC=97=90=20=EC=A0=80=EC=9E=A5=20?= =?UTF-8?q?=ED=9B=84=20=EB=A1=9C=EA=B7=B8=EC=9D=B8=20=EC=B2=B4=ED=81=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/App.js | 2 +- src/components/AuthRoute/AuthRoute.js | 13 +++++++++++-- src/store/Auth/auth.js | 2 ++ 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/src/App.js b/src/App.js index 4d17377..0205215 100644 --- a/src/App.js +++ b/src/App.js @@ -15,7 +15,7 @@ export default function App() { - + diff --git a/src/components/AuthRoute/AuthRoute.js b/src/components/AuthRoute/AuthRoute.js index 44b91fb..70176fe 100644 --- a/src/components/AuthRoute/AuthRoute.js +++ b/src/components/AuthRoute/AuthRoute.js @@ -1,11 +1,20 @@ -import React from 'react'; +import React, { useEffect } from 'react'; import { Route, Redirect } from 'react-router-dom'; -import { useSelector } from 'react-redux'; +import { useSelector, useDispatch } from 'react-redux'; import PropTypes from 'prop-types'; import { get } from '../../utils/snippet'; +import { setLogin } from '../../store/Auth/auth'; export default function AuthRoute({ component: Component, render, ...rest }) { + const dispatch = useDispatch(); const authSelector = useSelector(get('auth')); + useEffect(() => { + const name = sessionStorage.getItem('name'); + const email = sessionStorage.getItem('email'); + if (name !== authSelector.name) { + dispatch(setLogin({ email, name })); + } + }, []); return (