Skip to content

react-table support to readonly data #3748

@Pavinati

Description

@Pavinati

Discussed in #3648

Originally posted by Pavinati January 18, 2022
Seems like the table data prop is forced to be mutable. is it required to be mutable or is there a way around this?

type SomeRecord = Readonly<....>;

const columns: Column<SomeRecord>[] = [...];

type Props {
  className?: string;
  data: readonly SomeRecord[];
}

const MyTable = ({ className, data }: Props) => {
  return <Table className={className} columns={columns} data={data} />;
};

results in

The type 'readonly Readonly<SomeRecord>[]' is 'readonly' and cannot be assigned to the mutable type 'Readonly<SomeRecord>[]'.  TS4104
```</div>

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions