Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/reactjs/26.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Reactjs 如何将自定义接口作为道具传递到功能组件中_Reactjs_Typescript_React Props_Destructuring_React Functional Component - Fatal编程技术网

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} />