-
Notifications
You must be signed in to change notification settings - Fork 5
FE 코드 컨벤션
JEON TAEHEON edited this page Jul 16, 2024
·
7 revisions
const postList = [];
const addNumber = () => {};
const RANGE = {
min: 3,
max: 4,
} as const;
const MESSAGE_FORMATTER = {
add: (number) => `더할 숫자는 ${number}입니다.`,
} as const;
const MESSAGE = {
fail: "실패했습니다!",
success: "성공했습니다!",
} as const;
interface ComponentProps { ... }
type 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 { ExampleData } 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 [isOpen, setIsOpen] = useState(false);
const handleOpen = () => {
setIsOpen(true);
};
return (...);
}
/**
*
* @param { number } start
* @param { number } end
* @returns { boolean }
*/
//TODO 이 부분은 미정입니다. @본인닉네임
export const addNumber = (a: number, b: number): number => {
return a + b;
};
┣ component
┣ ┗ __tests__
┣ ┗ index.tsx
┣ ┗ Component.styled.ts
┣ otherComonent
┣ ┗ __tests__
┣ ┗ index.tsx
┣ ┗ OtherComponent.styled.ts
src
┣ folderNames
┣ otherFolderNames
...
interface PersonData {
name: string;
age: number;
address: string;
}
export default function Person({ name, age, address }: PersonData) {}
src
┣ apis
┣ assets
┣ components
┃ ┗ common
┣ ┗ header
┣ ┗ __tests__
┣ ┗ index.tsx
┣ ┗ Header.styled.ts
┣ ...
┣ constants
┣ hooks
┃ ┣ __tests__
┣ ┗ useExample.ts
┣ mocks
┣ pages
┣ queries
┣ types
┣ utils
┣ App.tsx