Skip to content
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

Merged
merged 5 commits into from
Aug 1, 2024
Merged

Conversation

darkdulgi
Copy link
Collaborator

@darkdulgi darkdulgi commented Jul 31, 2024

#️⃣ 연관 이슈

📝 작업 내용

차량의 간단한 정보를 보여줍니다. 차량 정보들은 처음엔 투명하다가 스크롤을 내려서 뷰포트가 차량 정보 섹션과 겹칠 시 애니메이션을 거쳐 나타납니다.
차량 정보들은 동일 경로 내 json 파일로 저장했습니다.
섹션이 나타나는 애니메이션이 끝나면 특정 문구가 하이라이트되는 애니메이션이 실행됩니다.

@darkdulgi darkdulgi added the feat 기능 구현 label Jul 31, 2024
Copy link
Collaborator

@lybell-art lybell-art left a 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`}>
Copy link
Collaborator

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;
Copy link
Collaborator

Choose a reason for hiding this comment

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

반복되는 부분을 별도의 변수로 떼신 것 아주 좋습니다.

Copy link
Collaborator Author

@darkdulgi darkdulgi Aug 1, 2024

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}
Copy link
Collaborator

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

import ContentSection from "./contentSection";

export default function SimpleInformation() {
const contentList = JSONData.content
Copy link
Collaborator

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;
Copy link
Collaborator

Choose a reason for hiding this comment

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

good

@lybell-art lybell-art merged commit 8acab20 into dev Aug 1, 2024
1 check passed
@darkdulgi darkdulgi linked an issue Aug 6, 2024 that may be closed by this pull request
3 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feat 기능 구현
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[feat] 메인-차량 기본정보
2 participants