Billy Bones
Billy Bones

Reputation: 2965

Property 'prop' does not exist on type 'IntrinsicAttributes & TableProp'.ts(2322)

I have a React component I am trying to pass a prop to. This is my first time seeing this error and from the other posts on it, I have not been able to resolve it on my end.

This is the shortened version of my code:

type TableProp = {};

function Table(prop: TableProp)
{
    //...
}

function Test()
{
    const testProp: TableProp = {
        // ...
    }

    return (
        <Table prop={ testProp }/>
    )
}

Now when I attempt to use this I get an error where I am setting prop for the Table component in Test()

The error reads:

Type '{ prop: TableProp; }' is not assignable to type 'IntrinsicAttributes & TableProp'.
Property 'prop' does not exist on type 'IntrinsicAttributes & TableProp'.ts(2322)

Upvotes: 0

Views: 1011

Answers (1)

Viet
Viet

Reputation: 12787

You just update like this:

<Table {...testProp }/>

Upvotes: 2

Related Questions