-
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
[feat] 차량 간단정보 구현 #56
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.
src/simpleInformation/index.jsx 에 세미콜론 추가해주시면 머지해 드리겠습니다.
<span | ||
key={index} | ||
style={highlightDynamicStyle} | ||
className={`${index % 2 ? style.highlightAnim : "text-neutral-800"} text-title-m whitespace-pre-wrap`}> |
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.
whitespace-pre-wrap은 json 데이터에서 \n을 대응하기 위해 사용하셨군요
|
||
useEffect(() => { | ||
const contentDOM = contentRef.current; |
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.
이렇게 안해주면 warning을 발생시킵니다. useRef로 선언한 개체는 current 속성을 통해 접근해야 하는데 여기서 current는 가변성이고 cleanup 함수가 실행되는 순간에는 화면이 업데이트 되고 난 뒤기 때문에 current의 값은 null로 세팅된다는 잠재적 문제가 있습니다.
https://velog.io/@cjhlsb/kencland
<div> | ||
{content.desc.map((str, index) => ( | ||
<span | ||
key={index} |
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에 index를 쓰는 건 썩 좋은 습관은 아닙니다. 왜냐하면 index를 key로 쓴 상태에서 배열이 바뀌거나 하면 리액트에서 뭐가 제대로 삭제 안 되거나 하는 버그가 생길 수 있어요.
(리액트 내부에서 key를 지정 안 하면 index를 key로 쓰긴 합니다. 그러지 말라고 오류 뱉는 거지만요.)
자세한 건 다음 링크를 참조하세요.
https://ko.react.dev/learn/rendering-lists#why-does-react-need-keys
src/simpleInformation/index.jsx
Outdated
import ContentSection from "./contentSection"; | ||
|
||
export default function SimpleInformation() { | ||
const contentList = JSONData.content |
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.
이거 왜 세미콜론이 없죠...?
@@ -2,8 +2,8 @@ import JSONData from "./contentList.json"; | |||
import ContentSection from "./contentSection"; | |||
|
|||
export default function SimpleInformation() { | |||
const contentList = JSONData.content | |||
|
|||
const contentList = JSONData.content; |
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.
good
#️⃣ 연관 이슈
📝 작업 내용