[英]Spread operator is not working in react typescript
我正在使用React +打字稿,遇到有关渲染组件的问题。
这是我尝试过的代码
filterCellComponent = ({ column, ...restProps }) => (
<TableFilterRow.Cell
column={column}
{...restProps} />
);
在以上方法中,我使用{column}变量执行某些条件,然后使用{... restProps}进行渲染。 但是我遇到语法错误,说缺少一些道具。 但是,当我调试时,所需的所有道具都在{... restProps}变量内。 我不明白为什么会这样。
知道为什么会这样吗?
谢谢
看来typescript无法确定column
的类型。 尝试像下面这样在函数签名中指定类型:
filterCellComponent = ({column, ...restProps}:InsertTypeHere) => (
为了澄清,问题在于filterCellComponent
现在可以接受任何具有列属性的对象。 但是TableFilterRow.Cell
希望column
为特定类型。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.