-
Notifications
You must be signed in to change notification settings - Fork 11
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
42gg-onboarding-fe-02 #3
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
고생하셨어요! 중복되는 부분은 custom hook으로 빼보는 연습하면 코드가 더 깔끔해질거에요.
const [auth, setAuth] = useRecoilState(authAtom); | ||
|
||
useEffect(() => { | ||
const authFromLocalStorage = JSON.parse(localStorage.getItem('auth')); | ||
if (authFromLocalStorage) | ||
{ | ||
setAuth(authFromLocalStorage); | ||
console.log(auth); | ||
} | ||
}, [setAuth]); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
이부분을 custom hook으로 바꾸면 Mainpage 함수를 사용 안해도 될거 같아요
function Header() { | ||
return ( | ||
<header> | ||
<nav className={styles.nav_item}> | ||
<Link to="/" className={styles.Home}> | ||
<Button style={{color: '#d0936d'}}>Bookjeok Bookjeok</Button> | ||
</Link> | ||
<Link to="/about"> | ||
<Button style={{color: '#d0936d'}}>About</Button> | ||
</Link> | ||
<Link to="/users"> | ||
<Button style={{color: '#d0936d'}}>Users</Button> | ||
</Link> | ||
<Link to="/Profile"> | ||
<Button style={{color: '#d0936d'}}>Profile</Button> | ||
</Link> | ||
</nav> | ||
</header> | ||
); | ||
} | ||
|
||
function Body() { | ||
const users = () => { | ||
return <Users />; | ||
}; | ||
return ( | ||
<Routes className={styles.bodypage}> | ||
<Route path="/*" element={<Home />} /> | ||
<Route path="/about" element={<About />} /> | ||
<Route path="/users/*" element={<PrivateRoute Component={users} />} /> | ||
<Route path="/profile" element={<Profile />} /> | ||
<Route path="/login" element={<LoginForm />}/> | ||
<Route path="*" element={<NotFound />} /> | ||
</Routes> | ||
) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
따로 파일로 빼는게 더 깔끔할 거 같아요.
구현