Reactjs 如何将自定义接口作为道具传递到功能组件中
我已经定义了一个接口Reactjs 如何将自定义接口作为道具传递到功能组件中,reactjs,typescript,react-props,destructuring,react-functional-component,Reactjs,Typescript,React Props,Destructuring,React Functional Component,我已经定义了一个接口CellState,我想把它作为道具传递给一个功能组件因为你没有在Cell组件中定义state道具 您可以将整个cellState对象展开,以满足Cell的属性要求,如下所示 <Cell {...cellState} /> function Cell(props: any, { location, clicked, mine, flagged, neighbors }: CellState) {} <Cell {...cellState} />
CellState
,我想把它作为道具传递给一个功能组件因为你没有在Cell组件中定义state
道具
您可以将整个cellState
对象展开,以满足Cell的属性要求,如下所示
<Cell {...cellState} />
function Cell(props: any, { location, clicked, mine, flagged, neighbors }: CellState) {}
<Cell {...cellState} />