-
Notifications
You must be signed in to change notification settings - Fork 0
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
[Week4/기본/생각] 로그인/회원가입 #6
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.
너무너무 수고했습니댜 !!!!
rem 단위 사용하기 연습, commit 더 작게 쪼개서 하는 법을 연습한다면 더 더 좋을것 같아용
갓기 최고🖤
week4/assign1/.env
Outdated
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.
env는 꼭꼭 gitignore에 추가해주기!!!
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.
헉 따로 추가해야하는거였구나!!!
.App{ | ||
width: 100%; | ||
height: 100%; | ||
display: flex; | ||
justify-content: center; | ||
align-items: center; | ||
} |
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.
요거 전역에 들어갈 설정인가용 ?! 그러면 globalStyle에 추가해줘도 된답니댜!
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.
App 컴포넌트 안에 있는 애들을 가운데로 오게하고 싶어서 한거예요!! 그래도 globalStyle에 해도 되나여??
week4/assign1/src/App.jsx
Outdated
<Routes> | ||
<Route path="/" element={<Login/>}/> | ||
<Route path="/signup" element={<Signup/>}/> | ||
<Route path="/Mypage/:userId" element={<Mypage/>}/> | ||
</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.
Router는 Router.tsx/jsx
파일 따로 만들어서 넣어주는걸 추천합니다!
width: 100%; | ||
height: 40px; | ||
border-radius: 10px; | ||
border: none; | ||
font-size:18px; |
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.
px 단위를 쓰는 이유가 있을까요?! width/height, font-size와 같은 반응형 구현이 필요한 부분은 rem을 쓰는걸 추천합니당!!
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.
아 맞다!! 저번에도 한번 추천받아서 생각해두고 있었는데 미처 신경을 못썼댜,,,🥲
background-color: ${({ $disabled,theme }) => ($disabled ? theme.colors.mainColor : '#ccc')}; | ||
color: ${({theme})=>theme.colors.white}; |
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.
theme 사용부터 props로 동적 스타일링까지!! 넘넘 완벽합니당🔥
#root{ | ||
height: 100vh; //중앙에 오게 하려고 했는데 이렇게 하는게 맞는지,,, |
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.
중앙에 오게 하려면 별도의 flex 설정이 필요할것 같네유
${props => props.$len&& | ||
css`width:200px`}; |
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.
scpt 단축어 사용해서 props 구조분해할당 하는것도 좋습니다!
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.
헐 $가 scpt단축어였던거군,, 방금빠르게구글링했을땐 잘안나오넹 ,, 멀로 구글링해봐야하지 ,,
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.
scpt.. 굳이네요.. 몰라서 다 직접 쳤는디,,,
week4/assign1/src/pages/Signup.jsx
Outdated
const checkDuplicate=(e)=>{ | ||
axios.get(`${API_URL}/api/v1/members/check?username=${username}`) | ||
.then(res=>{ | ||
res.data.isExist? setCheckDup(1):setCheckDup(2); |
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.
개인적인 의견인데..! 0,1,2도 좋지만 magic number 외에 한 눈에 의미를 알 수 있는 값으로 써줘도 좋을것 같아요!
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.
헉 너무 좋아요!! 섬세한 리뷰.. 감삼둥
week4/assign1/src/pages/Signup.jsx
Outdated
username&&password&&passwordCheck&&nickname&&(checkDup===2) ? setCanSignup(true): setCanSignup(false); | ||
console.log(canSignup); | ||
},[username,password,passwordCheck,nickname,checkDup]); |
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.
굿굿굿!!
week4/assign1/src/pages/Signup.jsx
Outdated
const [username,setUsername]=useState(""); | ||
const [password,setPassword]=useState(""); | ||
const [passwordCheck,setPasswordCheck]=useState(""); | ||
const [nickname,setNickname]=useState(""); | ||
|
||
//그외 | ||
const [checkDup,setCheckDup]=useState(0); | ||
const [canSignup,setCanSignup]=useState(false); |
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.
input 정보를 useState로 관리하면 하나 하나 값이 입력될 때마다 setState 함수가 실행 되어서 성능에 좋지 않다고 해요!
지금 구현 한 방식도 좋지만 나중에 1) input value를 ref로 관리하기, 2) 여러개의 input 정보를 하나의 state로 관리하기
등의 성능 향상을 위한 정보들도 찾아보면 더 좋을것 같습니당 !!
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.
헤헹 수연이 수고했ㅅ어!!!! 합세도 팟팅
@@ -0,0 +1,7 @@ | |||
.App{ | |||
width: 100%; |
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.
호옥시 App을 화면 꽉차게 구현하고 싶었던거라면? vw, vh 등을 활용해도 좋을거같아용
.App{ | ||
width: 100%; | ||
height: 100%; | ||
display: flex; |
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.
ㅎㅎㅎ 맞아여 헤헤
week4/assign1/src/App.jsx
Outdated
<Routes> | ||
<Route path="/" element={<Login/>}/> | ||
<Route path="/signup" element={<Signup/>}/> | ||
<Route path="/Mypage/:userId" element={<Mypage/>}/> |
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.
url path 구성할때는 소문자로 하는 것이 좋다고 하네용!!
공식 근거를 찾기위해서 영어로도 구글링을해봤으나 ,, 공식 레퍼런스는 아직 찾지 못했슴다 ,, 대신 스택오버플로우 레퍼런스를 총총 ,,
https://stackoverflow.com/questions/13511227/url-structure-lower-case-vs-upper-case
|
||
const Button = ({content,onClick,disabled}) => { | ||
return ( | ||
<ButtonSt onClick={onClick} $disabled={disabled}>{content}</ButtonSt> |
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.
옹 $이걸 붙인 이유는 그냥 disabled로 작성하면 비활성으로 인식해서 그런건가?? 이런 방법이 있었다니 ,,
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.
syled-component에 보낼 때 $를 붙여서 보내면 dom에는 영향을 미치지 않고 계산하는데에만 쓰인다고 하더라구!!
|
||
&:hover{ | ||
/* background-color: #f5d6d2; */ | ||
cursor: pointer; |
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.
섬세해요 ,,
margin: 30px 0; | ||
} | ||
|
||
.input{ |
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.
ㅋㅋㅋㅋㅋㅋㅋ 근데 나중에 보면 어떤건지 찾기 좀 힘들긴 하겠다!! 따로 만들어주는 습관 가져야게써
const Mypage = () => { | ||
const API_URL = import.meta.env.VITE_APP_URL; | ||
const nav=useNavigate(); | ||
const memberId=useParams().userId; |
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.
난 보통 이럴때
const memberId=useParams().userId; | |
const { userId } = useParams(); |
요로케 가져와서 userId 변수를 활용하는편이얌
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.
옹 이렇게 가져올 수도 있구나!!
week4/assign1/src/pages/Mypage.jsx
Outdated
<Container> | ||
<h1>My Page</h1> | ||
<section> | ||
<img alt='프로필 사진' src='https://search.pstatic.net/sunny/?src=https%3A%2F%2Fi.pinimg.com%2Foriginals%2F8e%2Fe6%2F82%2F8ee68280783c081cc1ecd7e20342d050.jpg&type=a340'/> |
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.
상단에 img를 import시켜서 src={변수명} 이런식으로 하면 깔끔해질거같당!
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.
+글구 나도 맨날깜빡하는데 alt에는 공백대신 -로 작성해주기 ㅎㅎ
setUsername(e.target.value); | ||
|
||
}}></Input> | ||
<DupBtn onClick={checkDuplicate} $checkDup={checkDup}>중복확인</DupBtn> |
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.
호옥시 checkDup앞에 $는 어떤 의미인가요옹.. 구글링해보고싶은데 어떤키워드로 해야할지 몰겠엉 헤헤
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.
요약하면 Prop 이름 앞에 $를 붙여 Transient Prop으로 만들면 styled-components는 이 prop을 스타일 계산에만 사용하고, 실제 DOM으로 전달하지 않는다고 해!!
https://velog.io/@sooy2/트러블-슈팅-props에-따라-styled-components에서-스타일-변경할-때-false값-전달하는-경우
저번에 트러블슈팅 기록했던거 벨로그로 옮겨놨어!! 함 봐두 좋을거같오!
${props => props.$len&& | ||
css`width:200px`}; |
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.
헐 $가 scpt단축어였던거군,, 방금빠르게구글링했을땐 잘안나오넹 ,, 멀로 구글링해봐야하지 ,,
🌱 기본 조건
.env
파일 사용하기🧩 기본 과제
[ 로그인 페이지 ]
/mypage/:userId
로 넘어갑니다. (여기서userId
는 로그인 성공시 반환 받은 사용자의 id)/signup
으로 이동합니다.[ 회원가입 페이지 ]
중복체크 버튼
회원가입 버튼
/login
으로 이동합니다.[ 마이 페이지 ]
/mypage/:userId
의 userId를 이용해 회원 정보를 조회합니다.🌠 심화 과제
[ 로그인 페이지 ]
createPortal
을 이용합니다.[ 회원가입 페이지 ]
비밀번호 확인
중복체크
생각과제
✨PR Point
0.
async.await을 정확히 언제 사용하는지, 왜 사용하는지를 아직 잘 모르겠어서 then으로 처리하긴 했는데 공부 해보면서 적용해보겠습니다!!
1. .env
2. 로그인
성공 했을 때
/Mypage/${res.data.id}
로 이동3. 회원가입
checkDup 변수를 검사 안했을 때 0, 중복일때 1, 중복 아닐 때 2 로 설정해서 styledComponents에서 색 변경 해주었습니다!!
각 경우가 모두 true이면 활성화 되도록 했습니다!
4. 마이페이지
params로 유저 id 받아와서 해줬습니다!!
https://www.notion.so/dosopt/4-49e44beb82e24779b4e3111904a7420c