[김제성] sprint 6#64
Hidden character warning
Conversation
modified html for index, login, signin and renamed img src
changed div, class names in camelCase
rl0425
left a comment
There was a problem hiding this comment.
고생하셨습니다. 많은 양을 단기간 내에 깔끔하게 해주셨는데, 네트워크 에러에 대한 예외처리나 기본 props에 대한 기본값 정의만 조금 더 해주시면 더 안전한 코드가 될 것 같습니다.
| } | ||
|
|
||
| const response = await fetch(url); | ||
| const data = await response.json(); |
There was a problem hiding this comment.
fetch()를 사용하시는거면, 응답 실패나 네트워크 오류에 대한 사용자 피드백 코드를 넣으시는 것이 좋을 것 같습니다.
const response = await fetch(url);
// HTTP 상태 확인
if (!response.ok) {
throw new Error(`HTTP error. status: ${response.status}`);
}
const data = await response.json();
// 데이터 유효성 검사
if (!data || typeof data !== 'object') {
throw new Error('Invalid response format');
}| }; | ||
|
|
||
| // 상품 상세 페이지 컴포넌트 | ||
| const ProductDetailPage = () => { |
There was a problem hiding this comment.
상세페이지나 404 페이지를 임시로 만들어 놓으신거여도, 추후 추가될 내용이라면 컴포넌트 파일을 별도로 분리하시는 것이 좋을 것 같습니다.
| import "./BestProductList.css"; | ||
|
|
||
| const BestProductList = ({ products }) => { | ||
| const bestProducts = products.slice(0, 4); |
There was a problem hiding this comment.
이전 리뷰에서 말씀드렸는지가 헷갈려서 한번 더 말씀드리면, products가 undefined이거나 배열이 아닐 경우 에러가 발생할 경우가 있으니 기본값 설정과 예외처리를 해주셔야 합니다.
const BestProductList = ({ products = [] }) => {
// 기본값 설정과 유효성 검사
if (!Array.isArray(products) || products.length === 0) {
...| return ( | ||
| <header> | ||
| <div className="top"> | ||
| <div |
There was a problem hiding this comment.
div 태그를 버튼으로 사용하시는거면 role 속성을 넣으셔서 접근성을 개선하시면 좋을 것 같습니다. 또 tabIndex를 사용하시면, 키보드 접근성도 해결할 수 있습니다.
<div
className="logo"
onClick={handleLogoClick}
role="button"
tabIndex={0}
aria-label="홈페이지로 이동"
>
...| @@ -0,0 +1,144 @@ | |||
| import React, { useState, useEffect } from "react"; | |||
There was a problem hiding this comment.
추후에 이 파일에서 ui 로직과 비즈니스 로직을 따로 분리하시는 작업을 하시면서, 관심사를 적절히 분리하는 방법을 공부하시는 것을 추천드립니다.
| import React from 'react'; | ||
| import './Pagination.css'; | ||
|
|
||
| const Pagination = ({ currentPage, totalPages, onPageChange }) => { |
There was a problem hiding this comment.
여기도, props를 그대로 밑에서 사용하시기 때문에 디폴트 값과 유효성 검사를 넣어주시는게 좋을 것 같습니다.
const Pagination = ({
currentPage = 1,
totalPages = 1,
onPageChange = () => {}
}) => {
// 기본값 설정, 유효성 검사
if (!totalPages || totalPages <= 1) {
return null;
}| <form onSubmit={handleSubmit} className="registrationForm"> | ||
| {/* 상품명 */} | ||
| <div className="formGroup"> | ||
| <label className="formLabel">상품명</label> |
There was a problem hiding this comment.
label과 input을 사용하실때는, htmlfor과 id로 서로 연결을 시켜주셔야 합니다.
<label htmlFor="product-name" className="formLabel">
상품명
</label>
<input
id="product-name"
type="text"
name="name"
...
요구사항
기본
심화
유효성 검사를 통과하지 않을 경우, 각 input에 빨간색 테두리와, 각각의 input 아래에 빨강색 에러 메시지를 보여주세요.
-> 유효한 조건 : 상품명: 1자 이상, 10자 이내
상품 소개: 10자 이상, 100자 이내
판매 가격: 숫자
태그: 5글자 이내
배포된 사이트
멘토에게
(오류 아니어도 어려워서 못했을 거 같기도 합니다 ㅎ...)