Pentagura
Pentagura

Reputation: 611

React Table: use multiple array

I want to use a React-Table with a lot of data.

Here is my data:

myData: {Array1:[{},{},...], Array2:[{},{},...], Array3:[{},{},...]}

So in my React-Table component, I do this:

<ReactTableFixedColumns data={myData} />

but it is not working. If I do *"data={myData.Array1}"*, I can see my data present in Array1. But I want to have all my data, not only the data in Array1.

Upvotes: 1

Views: 1252

Answers (1)

Clarity
Clarity

Reputation: 10873

You can combine all the data into one array:

const data = Object.values(myData).flatMap(arr => arr)

<ReactTableFixedColumns data={data} />

Upvotes: 4

Related Questions