react配合ts

253 阅读1分钟

1.interface定义规则

interface pageProps{num:number}

React.Component<Props,State>

interface person{one:string,two:string}
//对应规则
a({one:'a','two':'b'})
//调用时对参数传入规则a=(person:person)=>{}

2.组件插槽,传递组件元素到子组件

父组件:
<Composition color='red' ele={<FlavorForm />}></Composition>
子组件:
{props.ele}