React+TypeScript 컴포넌트 props

Franklee·2023년 1월 29일
0

Typescript

목록 보기
1/2
post-thumbnail
interface ParentProps{
  id:string;
  name:string;
  password:string;
}

function Parent(){
  const toChild : ParentProps = {
    id:'qwerty',
    name:'qt',
    password:'monkey'
  }
return(
  <div>
    <Child props={toChild}/>
    </div>
  )
}
type Childprops={
  props:ParentProps
}

function Child({props}:Childprops){
  return(
    <div>
    <p>{props.key}</p>
    </div>
  )
}
profile
복잡한 문제를 쉬운 코드로 해결해 나가는 개발자

0개의 댓글