-
Notifications
You must be signed in to change notification settings - Fork 1
π μ½λ λ° λ€μ΄λ° 컨벀μ
νμ΄μ§ μ»΄ν¬λνΈλ default export λ‘ λ΄λ³΄λ΄ μ£ΌμΈμ! μΆν lazy loading μ μν¨ μ λλ€!
export default function Page() {}νμ΄μ§λ₯Ό μ μΈν κΈ°ν μ»΄ν¬λνΈλ ν΄λΉ μ»΄ν¬λνΈ μ΄λ¦μΌλ‘ νμλλ ν 리λ₯Ό λ§λ€κ³ ,
index.tsx νμΌμ λ§λ€μ΄ μμ
ν΄μ£ΌμΈμ!
μ΄ν, νμ΄ν ν¨μλ₯Ό μ΄μ©ν΄ named export λ‘ λ΄λ³΄λ΄ μ£ΌμΈμ!
// src/components/MyComponent/index.tsx
export const MyComponent = () => {
return <></>;
};Props μ λν νμ
μ MyComponentProps μ κ°μ νμμΌλ‘ interface λ‘ μ§μ ν΄ μ£ΌμΈμ
// src/components/MyComponent/index.tsx
interface MyComponentProps {
children: React.ReactNode;
}
export const MyComponent = ({ children } : MyComponentProps) => {
return <></>;
};Props λ ꡬ쑰λΆν΄ν λΉμ μ΄μ©νμ¬ μ¬μ©ν΄μ£ΌμΈμ!
export const Good = ({ prop1, prop2 }) => {};export const Bad = (props) => {};Style μ»΄ν¬λνΈ (νΉμ μ»΄ν¬λνΈμ μ€νμΌλ§μλ§ μ¬μ©λλ μ»΄ν¬λνΈ) λ μ»΄ν¬λνΈ νμ λλ ν 리μ index.style.ts λ‘ νμΌμ λΆλ¦¬ν΄μ£ΌμΈμ
μ΄ν ν΄λΉ μ»΄ν¬λνΈκ° ꡬνλ νμΌμμ import * as Styles from "./index.style.ts"; μ κ°μ΄ μ¬μ©ν΄μ£ΌμΈμ
// src/component/MyComponent/index.tsx
import * as Styles from "./index.style.ts";
export const MyComponent = () => {
return (
<Styles.Wrapper>
<Styles.Container>
<Styles.Item></Styles.Item>
<Styles.Item></Styles.Item>
</Styles.Container>
</Styles.Wrapper>
);
};// MyComponent.style.tsx
export const Wrapper = styled.div``;
export const Container = styled.div``;
export const Item = styled.div``;5οΈβ£ λ€μ΄λ° 컨벀μ
CSS Style MixIn μ snake_case λ‘,
μΌλ° ν¨μ / λ³μλ camelCase λ‘,
μ»΄ν¬λνΈλ PascalCase λ‘ μμ±ν΄μ£ΌμΈμ!
// src/style/utils.ts
import { css } from "@emotion/react";
export const place_center = css`
display: flex;
justify-content: center;
align-items: center;
`;// src/store/auth.slice.ts
export const authSlice = createSlice({
name: "getp/auth",
initialState,
// ...
});export const MyComponent = () => {};νμ μ»΄ν¬λνΈ λͺ
μ λͺ
λͺ
νκΈ° μ΄λ €μΈλ μ°Έκ³ νμλ©΄ μ’μ λ― ν©λλ€!
μ λ Wrapper > Container > (Items) > Item > β¦ μΌλ‘
μΈλ¨κ³μ νμ Element λ‘ λΆλ¦¬λλ κ²½μ° Header Body Footer λ‘ μλͺ
νλ νΈμ
λλ€