I am using React + typescript and encountered with a problem regarding rendering a component.

Here is the code of what I have tried

filterCellComponent = ({ column, ...restProps }) => (
        <TableFilterRow.Cell
            column={column}
            {...restProps} />
    );

In the above method, i use the {column} variable to perform some conditions and then I render the with use of {...restProps}. But I am getting a syntax error saying some props are missing. But when I debug, all the props that are required are inside the {...restProps} variable. I do not understand why this is happening.

Here is the image that shows the error: enter image description here

And this is the error message that i'm getting enter image description here

Any idea on why this is happening?

Thanks

1 Answers

4
pgsandstrom On Best Solutions

It seems as if typescript cant determine the type of column. Try specifying the types in the function signature like this:

filterCellComponent = ({column, ...restProps}:InsertTypeHere) => (

To clarify, the problem is that filterCellComponent right now accepts any object that has a column-property. But TableFilterRow.Cell wants column to be a specific type.