-
[타입스크립트] 연습장typescript 2021. 6. 11. 00:11반응형
interface Istate { people:{ age:number, name:string, note?:string, }[] } function App() { const [people, setPeople] = useState<Istate["people"]>([])
prop으로 들어가는것도 타입지정해줘야함다.
<List people={people}/> interface IProps { people:{ age:number, name:string }[] } function List({people}:IProps) { return ( <div> I am List </div> ) } === const List : React.FC<IProps> = () => { return ( <div> I am List </div> ) }
두가지가 같은표현이다.
const renderList = () : JSX.Element[]
'typescript' 카테고리의 다른 글
[typescript] 연습장(예시) (0) 2021.06.15 [타입스크립트] typeguard (0) 2021.06.15 [타입스크립트] enum ?? (0) 2021.06.04 [타입스크립트] 제네릭 에 대하여 (0) 2021.06.03 [타입스크립트] interface 와 type 의 차이 (1) 2021.06.01