Home > Net >  Type has no properties in common with type 'ColumnType<any>'
Type has no properties in common with type 'ColumnType<any>'

Time:01-03

I am writing an app with react and ant design

I want to use antd table

but it does not show my data

Code

const ListOfProperties = () => {
  const columns = [
    {
      type: "Type",
      state: "State",
      location: "Location",
    },
  ];
  const properties = [
    {
      type: "Flat",
      state: "Anambra",
      location: "Udoka",
    },
    {
      type: "Flat",
      state: "Anambra",
      location: "Udoka",
    },
  ];
  return (
    <Skeleton active loading={loading}>
      <Table columns={columns} dataSource={properties} />
    </Skeleton>
  );
};

export default ListOfProperties;

I created an array of objects which I passed to the data source and columns to the columns

as stated in the docs

but I am getting error

Error

Type '{ type: string; state: string; location: string; }' has no properties in common with type 'ColumnType<any>'.

CodePudding user response:

you need to provide title, dataIndex and key. Always look it up in the documentation first.

const columns = [
  {
    title: "Type",
    dataIndex: "type",
    key: "type"
  },
  {
    title: "State",
    dataIndex: "state",
    key: "state"
  },
    {
    title: "Location",
    dataIndex: "location",
    key: "location"
  },
 ];
  • Related