-
Notifications
You must be signed in to change notification settings - Fork 10
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
[4주차] 김동혁 미션 제출합니다. #14
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.
과제 너무 수고많으셨어요 > <
코드리뷰 보시고 궁금한 것이 있다면 언제든지 물어봐주세요 😆
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.
indent가 4로 되어있나봐요 !!
그럴 경우 코드가 점점 복잡해지고 tag가 점점 중첩될수록 코드를 읽기 불편해져서 많이들 하는 indent size 2로 하시는 걸 추천드려요오 !!
handleClickChat(chat.id); | ||
}} | ||
> | ||
<Profile src="/icon/ChatProfile.svg" /> |
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: 2, name: '이수현', message: '안녕하세요!', time: '오전 9:20', unreadCount: 0 }, | ||
// { id: 3, name: '박지민', message: '오랜만이에요.', time: '오후 1:45', unreadCount: 1 }, | ||
]); |
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.
헛 여기 일부러 주석처리하신 걸까요?? 정수완 밖에 안보여요 ..!!
{chats.map(chat => ( | ||
<Chat1 | ||
key={chat.id} | ||
onClick={() => { | ||
handleClickChat(chat.id); | ||
}} |
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.
map도 마찬가지로 chat.~ 로 각 프로퍼티에 접근하고 잇는걸 그냥 프로퍼티명으로 바로 접근할 수 있는 구조분해할당 방식도 있다는거 ..! > <
chat.map((chat) => {
const {id, name, time, message} = chat;
<Chat1
key = {id}
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.
와 저도 배워갑니다...!
</NameSpace> | ||
|
||
<NameSpace> | ||
<Message>{chat.message}</Message> |
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 { chatMessagesState } from '../../../context/ChatDataState'; | ||
import type { YourFirstMessageProps } from '../../../lib/types'; | ||
|
||
export default function YourFirstMessage(props: YourFirstMessageProps): JSX.Element { |
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.
props.~ 로 각 프로퍼티에 접근하고 잇는걸 그냥 프로퍼티명으로 바로 접근할 수 있는 구조분해할당 방식이 있다는 점도 있어요 !! 아래 한 줄 만 추가해서 쓰면 되니까 참고하세요 > <
const {isContinuous, sentTime, 등} = props;
{!props.isContinuous && <Profile src="/ChatRoom/defaultProfile.svg" alt="profile" />} | ||
<TextContainer> | ||
{!props.isContinuous && <ProfileName>{props.name}</ProfileName>} | ||
<Chat> | ||
{props.isContinuous && <div style={{ marginLeft: '48px' }}></div>} | ||
<ChatBox>{props.message}</ChatBox> | ||
{!props.isContinuous && <ChatTail />} | ||
<SentTime>{props.sentTime}</SentTime> | ||
</Chat> |
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.
위에 말한 것처럼 구조분해하면 여기 props.~으로 접근하는 프로퍼티들 싹다 그냥 프로퍼티로 쓸 수 있답니다 ㅎㅎ
// if (user === me.name) { | ||
// setUser(opposite.name); | ||
// setOppositeChat(me.name); | ||
// } else { | ||
// setUser(me.name); | ||
// setOppositeChat(opposite.name); | ||
// } |
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.
삼항연산자 쓰신거 너무 좋아요 !! 그럼 불필요한 주석을 지워주세요 ㅎㅎ
function formatDate(dateString: string): string { | ||
const options: Intl.DateTimeFormatOptions = { | ||
year: 'numeric', | ||
month: 'long', | ||
day: 'numeric', | ||
weekday: 'long', | ||
}; | ||
return new Date(dateString).toLocaleDateString('ko-KR', options); | ||
} | ||
|
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.
이렇게 날짜를 포맷하는 방법도 있군요 ! 새롭게 배워갑니다 ㅎㅎ
export const initialChats = [ | ||
{ id: 1, opposite: { name: 'Alice' }, messages: [{ text: 'Hello!', sentDate: '2023-01-01' }] }, | ||
{ id: 2, opposite: { name: 'Bob' }, messages: [{ text: 'Hi there!', sentDate: '2023-01-02' }] }, | ||
]; |
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.
initialChats는 이번에 사용 안하시는 걸까용? 배포에서는 이 부분이 안보이네요 !!
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.
동혁님 이번 과제도 수고 많으셨습니다! 컴포넌트를 기능과 스타일을 따로 만드신 부분도 좋았던거 같아요! svg 관련 부분도 많이 배워갑니다! 다음 과제도 화이팅 해봐요😁
svg { | ||
${({ isActive }) => | ||
isActive | ||
? css` | ||
fill: black; | ||
` | ||
: css` | ||
fill: none; | ||
`} | ||
} | ||
`; |
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.
svg로 불러오면 css를 다르게 줄 수 있어서 좋은거 같아요! 저도 이렇게 구현하고싶었는데 계속 오류가 나서 이번과제에는 적용하지 못했는데 배워갑니당!
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.
footer부분은 하나의 파일로 통일시켜도 좋을거 같아요...! 기능이 많지 않아서 하나의 컴포넌트로 줄이는게 유지보수하기에도 좋지 않을까.. 생각해봅니당ㅎㅎ
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.
기능 끼리 모아두고 스타일은 따로 두신 것도 깔끔하고 좋은거 같아요!
{chats.map(chat => ( | ||
<Chat1 | ||
key={chat.id} | ||
onClick={() => { | ||
handleClickChat(chat.id); | ||
}} |
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 Questions
1. Rouing 이란?
2. SPA란?
3. 상태관리란?