-
Notifications
You must be signed in to change notification settings - Fork 5
[현명] 로그인 과제 제출 #8
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
base: main
Are you sure you want to change the base?
Conversation
feat: 타입스크립트로 전환 + 이전파일 이동
타입스크립트 전환
로그인 페이지 UI구현
로그인 기능 리팩터링
-버튼 가운데 정렬
main 브랜치에 merge
Refactor
메인 브랜치 병합
테스트시 에러메세지 alert
Protected router 구현
Refatoring
refactor: useInput 커스텀훅 구현
kwakseongjae
left a comment
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.
커스텀훅 시도 너무 좋았다.
왜 잘 해 ??
나 무서워 ,,
합격 !! 😎✌
| {/*로그인 유저만 접근가능 */} | ||
| <Route element={<ProtectedRouter />}> | ||
| <Route path="/mypage" element={<MyPage />} /> | ||
| </Route> |
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.
시도 조씁니다 👍👍
| import axios from "axios"; | ||
|
|
||
| const AuthApi = axios.create({ | ||
| baseURL: "http://localhost:8000/auth", |
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.
막히면 레퍼런스 물어봐 !
생각보다 적용하기 쉬워 !
https://i-ten.tistory.com/256
| @@ -0,0 +1,23 @@ | |||
| import styled, { css } from "styled-components"; | |||
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.
css는 어디서 쓰였나요 ?
|
|
||
| const [errorMsg, decideErrorMsg] = useErrorMsg(); | ||
| const location = useLocation(); | ||
| const from = location?.state?.redirectFrom?.pathname || "/"; |
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.
좋은 레퍼런스 찾았나보네 👍👍
자주 사용되니까 꼭 외워둬 !
| <label htmlFor="email">이메일</label> | ||
| <input | ||
| name="email" | ||
| placeholder="ssafe11@gmail.com" | ||
| onChange={handleEmailChange} | ||
| /> |
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.
id 선택자 추가하셔야지 !!
| <Button active={isActive} onClick={handleBtnClick}> | ||
| 회원가입 | ||
| </Button> |
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.
onClick, handleSubmit, handleSignup 등의 좋은 변수명도 많습니당 :)
handleBtnClick은 저는 잘 안쓸거같네용
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.
개멋지다... 미쳤다... 👍👍
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.
뭔데 이거 !!!
잘짠거같은데 왜 안썼어 ??
| <Link to="/signup"> | ||
| <Button>회원가입</Button> | ||
| </Link> | ||
| <Link to="/login"> | ||
| <Button>로그인</Button> | ||
| </Link> | ||
| <Link to="/mypage"> | ||
| <Button>마이페이지</Button> | ||
| </Link> |
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.
NavLink를 아시나요 ?
https://velog.io/@seong-dodo/React-Link%EC%99%80-NavLink
| {accessToken ? ( | ||
| <Outlet /> | ||
| ) : ( | ||
| <Navigate to="/login" state={{ redirectFrom: currentLocation }} /> | ||
| )} |
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.
시도는 좋은데 조금 더 컨벤션을 찾아보면 좋을거같다는 생각 !
제로 베이스로 떠올린거면 꽤 준수하넹
if문이랑 return이 있는 레퍼런스 한번 찾아봐 !
보통은 그렇게 많이 작업해 !
SSAFE 4차 MISSION: 타입스크립트와 API를 이용한 회원가입&로그인
2주차 구현 내용
1️⃣ [Protected Router 적용]
Protected Router 코드
2️⃣ [회원가입 Input에 reducer적용]
Reducer 코드
3️⃣ [로그인 Input에 커스텀훅 적용(useInput)
커스텀훅 코드
ProtectedRouter 작동 영상
2024-03-14.10.16.36.mov
✏️ 파일 구조
입력과유효성 검사를 담당하는 컴포넌트시도했지만 실패
커스텀훅을 다른 곳에서도 사용
환경변수로 baseURL을 설정
마이페이지를 로그인 시에만 보이도록