Reputation: 225
When I'm upgrading Tanstack react-table from V7 to V8, I stuck with some problems.
Before V8, if we want to display customized cell, we can use the props in columns defs.
Cell: (props) => <CustomizeCell cellProps={props.data} //>
Then I can get the real type/interface e.g. Type Person in the customizeCell, to display person.name or person.email.
But now in V8, I can't figure out how to get the props.data.
From the Tanstack doc sample, we can columnHelper.display, then I use the property
Cell: (props) => <CustomizeCell cellProps={props.row.original} //>
Now, I can get the person object in the CustomizeCell using person.name or person.email. There is another question, my Person Type defs is
Type Person = {
name: string,
email: string
}
But the backend response object contains some more properties, e.g.
class Person {
public string name;
public string email;
public string city;
}
As above code, the frontend type Person doesn't have city property against backend type. When I get the Person object from frontend, we person object does have city property event I don't define it in our type.
I use tanstack query to get response from backend API.
Does anyone indicate why frontend object can have the properties are not defined inside type but live in backend response object?
Is this something related to Tanstack react query or general API feature?
Upvotes: 0
Views: 457