-
Notifications
You must be signed in to change notification settings - Fork 0
코딩 컨벤션
황유빈 edited this page Dec 6, 2024
·
2 revisions
const postList = [];
const addNumber = () => {};
const SOME_CONSTANT = 1;
const RANGE = {
min: 3,
max: 4,
} as const;
interface ComponentProps { ... }
interface MissionListData {
...
}
export default function MissionList (data : MissionListData){}
const isValidValue = true;
const hasValue = false;
const canEnter = true;
type UseRangeParams = {
min: number;
max: number;
};
const useRange = ({ min, max }: UseRangeParams) => {};
const handleMissionLevelValue = () => {};
export default function Component() {
const handleMissionLevelValue = () => {
// ...
};
return <OtherComponent onHandleMissionLevelValue={handleMissionLevelValue} />;
}
import type { PropsWithChildren } from 'react';
export default function Wrapper({ children }: PropsWithChildren) {
return <div>{children}</div>;
}
const getMission = () => {};
const postMission = () => {};
const deleteComment = () => {};
네이밍 | 설명 |
---|---|
Container |
컴포넌트의 최상단 |
Wrapper |
여러 개의 요소든 단일 요소든 감싸줘야 할 때 |
List |
ul , ol 태그를 사용할 때 권장 |
Item |
li 태그, 반복되는 요소를 사용할 때 권장 |
각 항목은 Component명
+ 네이밍
으로 조합한다.
import type { ExampleType } from '@types/types';
export default function Component() {}
import * as S from './Component.styled';
┣ ┗ component
┣ ┗ index.tsx
┣ ┗ Component.styled.ts
export const function = () => { ... };
export const Container = styled.div;
export const MESSAGE = {} as const;
export default function Component() {
const [data, setData] = useState(false);
const handleOpen = () => {
setIsOpen(true);
};
return (...);
}
export const addNumber = (a: number, b: number): number => {
return a + b;
};
src
┣ folderNames
┣ otherFolderNames
...
- Component 폴더 이름은 파스칼로!
- Component 폴더 내 메인이 되는 컴포넌트는 index.tsx로 네이밍!
type SomeType = {
asd: sasdad
}
interface PersonData {
name: string;
age: number;
address: string;
}
export default function Person({ name, age, address }: PersonData) {}