-
Notifications
You must be signed in to change notification settings - Fork 10
[4주차] 김영서 과제 제출합니다. #15
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: master
Are you sure you want to change the base?
Conversation
앞으로 다음과 같은 규칙을 적용함 리액트 컴포넌트: *.tsx 스타일드 컴포넌트: *.Styled.ts 단순 객체, 자바스크립트 함수, 스타일 정의 등: *.ts
uuidv4()로 고유하게 관리
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 lastSenderRef = useRef<number | null>(null) | ||
const lastSentTimeRef = useRef<number | null>(null) | ||
const chatWrapperRef = useRef<HTMLDivElement | null>(null) | ||
|
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.
Ref 깔끔하게 잘 사용하신 것 같습니다!
{dateChatPair.map(([date, chat], dateIdx) => ( | ||
<div key={date}> | ||
{<ChatDate date={date} dateIdx={dateIdx} />} | ||
{chat.map(({ id, content, sender }: Chat, chatIdx: 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.
key값 빠져있는 것 같습니당
<s.ChatDiv $isR={true} $isMe={isMe}> | ||
<div>{content}</div> | ||
</s.ChatDiv> | ||
{!isMe && souldDisplayTime ? ( |
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 determineLastSender = (sender: number): boolean => { | ||
const isLastSender = sender === lastSenderRef.current | ||
lastSenderRef.current = sender | ||
return isLastSender | ||
} | ||
|
||
const determineLastMsgSentSameTime = (curTime: number): boolean => { | ||
const curMinuteTimestamp = Math.floor(curTime / 60000) | ||
const isLastMsgSentSameTime = curMinuteTimestamp === lastSentTimeRef.current | ||
lastSentTimeRef.current = curMinuteTimestamp | ||
return isLastMsgSentSameTime | ||
} | ||
|
||
const determineSentSameTime = ( | ||
curTime: number, | ||
nextTime: number | ||
): boolean => { | ||
const curMinuteTimestamp = Math.floor(curTime / 60000) | ||
const nextMinuteTimestamp = Math.floor(nextTime / 60000) | ||
return curMinuteTimestamp === nextMinuteTimestamp | ||
} |
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.
컴포넌트가 랜더링 될 때마다 함수가 다시 생성되는걸 방지하기 ㅇ위해..
if (chatRoomRef === roomId) { | ||
createChatRoom(roomId, member) | ||
enterChatRoom(roomId) | ||
} | ||
addChat(roomId, newChat) | ||
updateLastSeenTime(roomId) |
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.
제가 코드를 꼼꼼히 보지는 못했는데 여기서 Ref랑 id랑 값이 같은데 왜 createChatRoom인지 이해가 부족한 것 같습니다
배포 링크
https://react-messenger-21th-five.vercel.app/
느낀점
KQ
1. React Router의 동적 라우팅(Dynamic Routing)이란 무엇이며, 언제 사용하나요?
URL 경로에 변수를 포함해 라우트를 설정하는 방식으로
:id
파라미터를 이용해 구현한다.UI는 같지만 데이터가 동적으로 달라지는 페이지에서 사용하며 보통 상세 페이지에 해당하는 페이지에서 주로 사용한다.
2. 네트워크 속도가 느린 환경에서 사용자 경험을 개선하기 위해 사용할 수 있는 UI/UX 디자인 전략과 기술적 최적화 방법은 무엇인가요?
3. React에서 useState와 useReducer를 활용한 지역 상태 관리와 / Context API 및 전역 상태 관리 라이브러리의 차이점을 설명하세요.
지역 상태 관리
전역 상태 관리