-
[오픈마인드] 클래스네임 classname코드잇 2024. 1. 22. 23:41
``` .buttonArea { width: 100%; text-align: end; padding-bottom: 69px; button { ```
이틀 전에 팀원 코드 리뷰를 남기다가 button 태그에 클래스 네임을 적지 않은 부분을 보고 피드백을 드렸다.
tag에 직접 스타일을 주면 유지보수가 힘들어 질 수 있어요! 하나의 파일 안에서도 div 태그의 하위 태그들이 많아지게 된다면 겹치는 요소들도 많아져서 미리 className을 작성하는 거라고 생각을 해요. 지금은 겹치는 요소가 없다는 부분을 인지하고 있지만 나중에 코드를 리팩토링하거나 다른 팀원들이 개발할 때 헷갈릴 수 있을 것 같아요.
css의 경우에는 파일마다 겹칠 수 있기 때문에 클래스 네임을 습관화 해주는게 좋다.
스타일드 컴포넌트나 SCSS는 전역쪽이나 부모 태그쪽에는 클래스 네임을 적어야 되겠지만, 자식 태그에는 클래스 네임을 꼭 쓸 필요가 없다고 한다. 이런 부분은 취향 차이라고 한다.
무조건 클래스 네임을 다 적어야 줘야 하는줄 알았는데 잘못된 생각을 가지고 있었다.
그래서 피드백을 수정해서 다시 팀원에게 전달했다.
'코드잇' 카테고리의 다른 글
[오픈마인드] 이전에 merge된 커밋들이 보이는 이슈 (0) 2024.01.25 [오픈마인드] 깃허브 merge하면 자동으로 이슈닫히게 (0) 2024.01.23 [오픈마인드] git 대소문자, github merge, svg 색상 변경 (0) 2024.01.21 [오픈마인드] eslint jsx 이슈, 헤더 스타일링 (0) 2024.01.20 [오픈마인드] eslint 문법 이슈 (0) 2024.01.20