Skip to content

[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

Open
wants to merge 123 commits into
base: master
Choose a base branch
from

Conversation

kkys00
Copy link

@kkys00 kkys00 commented Apr 26, 2025

배포 링크

https://react-messenger-21th-five.vercel.app/

느낀점

  1. 스타일드 컴포넌트가 이제 업데이트되지 않고 나중에 문제가 될 수 있다고 해서 tailwind로 리팩터링 했는데, tailwind가 파일 구조도 깔끔해지고 훨씬 쉬운 것 같습니다...
  2. 처음 채팅방만 개발할 때 로컬 스토리지에 저장할 것을 염두에 두고 만들지 않아서 확장하다 보니 데이터 구조가 약간 이상해진 것 같아서 아쉬운 것 같습니다.
  3. 디자이너님과 얘기하다보니 기능이 점점 추가돼서 생각보다 더 확장되어서 재밌게 작업했습니다.
image

KQ

1. React Router의 동적 라우팅(Dynamic Routing)이란 무엇이며, 언제 사용하나요?

URL 경로에 변수를 포함해 라우트를 설정하는 방식으로 :id 파라미터를 이용해 구현한다.
UI는 같지만 데이터가 동적으로 달라지는 페이지에서 사용하며 보통 상세 페이지에 해당하는 페이지에서 주로 사용한다.

2. 네트워크 속도가 느린 환경에서 사용자 경험을 개선하기 위해 사용할 수 있는 UI/UX 디자인 전략과 기술적 최적화 방법은 무엇인가요?

  1. UI/UX
    1. 미리 UI 뼈대 보여주기
    2. 로딩 바, 링 등으로 진행 중임을 표시
    3. 핵심 콘텐츠 우선 렌더링
    4. 연결 상태를 사용자에게 알려주기
  2. 기술적 최적화
    1. 이미지 최적화
    2. 스크롤이나 중요도에 따라 컴포넌트나 이미지를 지연 로딩
    3. 캐싱
    4. 서버 사이드 렌더링 또는 정적 페이지 먼저 보내기

3. React에서 useState와 useReducer를 활용한 지역 상태 관리와 / Context API 및 전역 상태 관리 라이브러리의 차이점을 설명하세요.

  1. 지역 상태 관리

    1. useState: number, string 등의 간단한 상태 관리
    2. useReducer: 객체, 객체 배열 등의 복잡한 로직이 필요한 상태나 여러 상태를 함께 관리할 때 사용
  2. 전역 상태 관리

    1. Context API: 리액트에 내재된 전역 상태 공유 도구, 다크모드나 로그인 정보 등의 비교적 가벼운 전역 상태를 관리하고 싶을 때 사용
    2. 전역 상태 관리 라이브러리: 큰 규모의 앱이나 복잡한 전역 상태를 관리하고 싶을 때 사용
      1. Zustand: 간단한 경량 상태 관리 라이브러리, 작은 규모의 프로젝트에 적합
      2. Redux: Flux 아키텍처(action -> reducer -> store) 기반 상태 관리 도구, 대규모 프로젝트에 적합
      3. Recoil: React 전용 상태 관리 라이브러리로 컴포넌트 단위의 선언형 상태 관리

kkys00 added 30 commits March 25, 2025 13:27
앞으로 다음과 같은 규칙을 적용함
리액트 컴포넌트: *.tsx
스타일드 컴포넌트: *.Styled.ts
단순 객체, 자바스크립트 함수, 스타일 정의 등: *.ts
kkys00 added 29 commits April 15, 2025 21:02
Copy link

@BeanMouse BeanMouse left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

엄청 잘 구현 하신거 같아요! 실제 채팅 방으로 써도 문제가 없을듯..!

코드 외적인 부분을 조금 말하자면 커밋 메시지에 규칙을 정하시고 하셔도 좋을 것 같습니다

Comment on lines +33 to +36
const lastSenderRef = useRef<number | null>(null)
const lastSentTimeRef = useRef<number | null>(null)
const chatWrapperRef = useRef<HTMLDivElement | null>(null)

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) => {

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 ? (

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

변수명에 오타 난것 같습니다

Comment on lines +48 to +68
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
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

컴포넌트 바깥에 위치 시키는건 어떨까 싶습니다

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

컴포넌트가 랜더링 될 때마다 함수가 다시 생성되는걸 방지하기 ㅇ위해..

Comment on lines +35 to +40
if (chatRoomRef === roomId) {
createChatRoom(roomId, member)
enterChatRoom(roomId)
}
addChat(roomId, newChat)
updateLastSeenTime(roomId)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

제가 코드를 꼼꼼히 보지는 못했는데 여기서 Ref랑 id랑 값이 같은데 왜 createChatRoom인지 이해가 부족한 것 같습니다

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants