📋 목차
구분 | 기술 | 비고 |
---|---|---|
번들러 | Vite | CRA vs Vite |
axios vs fetch
풀네임 사용 여부 | 축약형보다는 풀네임을 권장 |
---|---|
길이 제한 | 4음절로 제한 |
컴포넌트 작성 순서 | styled-components > hook(상태) > 상수 > 변수 > 함수 > jsx |
JSDoc | 공통 컴포넌트, 함수 등 |
함수 형태 | 컴포넌트는 함수 선언식 export default function Component(){} |
그 외 함수는 함수 표현식 export const Fn = () ⇒ {} |
분류 | 규칙 | 예시 |
---|---|---|
상수 | SNAKE_CASE | const MAX_USERS = 10; |
변수 | camelCase | let userName = 'JohnDoe'; |
let isActive = true; | ||
let hasLoggedIn = false; | ||
함수 | camelCase, 동사+명사 | const getUserProfile = () ⇒ { ... } |
이벤트 핸들러 | camelCase | |
컴포넌트에 props 넘겨줄 때는 on 접두사 | ||
이벤트 함수는 handle 접두사 | props -> onChangeHandler | |
func -> handleChange | ||
타입, 인터페이스 | - type : 유니언 타입, 유틸리티 타입 |
interface : 타입 외 나머지
접미사 Props | interface AvatarProps {…} type AvatarProps {…} | | 타입 별칭 | - 접미사 Type | type ButtonType = …; | | 인터페이스 | PascalCase | | | 컴포넌트 | PascalCase | Avatar |
export default function Button({
type = 'button',
disabled = false,
width = '13.3rem',
height = '4.3rem',
shape,
...props
}: ButtonProps) {
const theme = useTheme();
return (
<BaseButton
type={type}
disabled={disabled}
$width={width}
$height={height}
$shape={shape || theme.shape.round}
{...props}
>
{isLoading && <CircularProgress size={20} />}
{!isLoading && children}
</BaseButton>
);
}
import styled, { css } from 'styled-components';
export const BaseButton = styled.button<StyledButtonProps>`
${({
$width,
$height,
theme,
}) => css`
width: ${$width};
height: ${$height};
// theme 사용 예시
border-radius: ${$theme.shape.round};
color: ${theme.color.black_primary};
`}
`;
AlgoBaro
├─ 📂 public // 파비콘 등 자료나 이미지
│ └─ favicon.ico
└─ 📦 src
├─ 📂 assets
├─ 📂 components
├─ index.ts
└─ 📂Common // 공용 컴포넌트 폴더
└─ 📂Avatar
├─ index.ts // 폴더 내 .tsx 파일이 하나일 경우 생략
├─ Avatar.tsx
└─ Avatar.style.ts
├─ 📂 constants
├─ 📂 hooks
├─ 📂 pages
├─ 📂 routes
├─ 📂 services
├─ 📂 auth
└─ apiconfig.ts
├─ 📂 store
├─ 📂 styles
├─ 📂 types
├─ 📂 utils
├─ App.tsx
└─ main.tsx
├─ .gitignore
├─ index.html
└─ README.md