Interface1 [TypeScript]나만 보는 TypeScript 기초 메모장(컴포넌트 간 요소 전달 (Props)와 interface의 역할) React에서 컴포넌트 간에 데이터를 전달할 때 Props(속성)interface는 이 Props의 구조(타입)를 정해주는 역할interface의 역할interface MemoItemProps { task: string; //내용 index: number; //해당 할 일의 배열 내 위치(인덱스) onDelete: (index: number) => void; //삭제함수(인덱스를 전달받아야 함)}interface는 MemoItem 컴포넌트가 받아야 하는 props의 형태를 정의하고 반드시!! task, index, onDelete라는 3가지 값을 꼭 넘겨야함.onDelete: (index: number) => void;를 쓰는 이유onDelete가 어떤 타입의 함수인지 미리 정의(onDe.. 2025. 2. 16. 이전 1 다음