[英]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.