0

hey guys can anyone help how to map on two different array of object on same react material ui table ? i searched alot but i am not getting it . actually i want to show data in my table from two array of objects . i want to show data from appData into id , firstname, and last name and in table address column and attended column i want to show data from rows. i am attatching screenshot all i am trying to do after learning from google . enter image description here enter image description here

2
  • Please do not provide screenshots but insert your code in the question so it is easier for us to reproduce your problem and help you. Commented Jun 14, 2022 at 12:38
  • anyone knows PLEASE? Commented Jun 14, 2022 at 12:42

1 Answer 1

2

index is just a number. It does not have these properties (address, attended). If you want the properties, you can simply write data.address or data.attended.

<TableCell align="left">{data.address}</TableCell>
<TableCell align="left">{data.attended}</TableCell>

You can also write something like rows[index].address but I recommend the first way.

EDIT

I am sorry. I thought you are using map on the rows array. This is what you can do to get data from the rows array:

<TableCell align="left">{rows[index].address}</TableCell>
<TableCell align="left">{rows[index].attended}</TableCell>

Hope this helps.

Sign up to request clarification or add additional context in comments.

5 Comments

no this is not what i am asking . i dont want to get the data from data for address and attended . i want to get the data for address and attended from different array of object which name is rows . please check above screenshots . and i want to show the data from appData into id firstname and into last name . i was using rows[index] because i learn it from stackoverflow diff post but that was not helpful because they was simply using array and here in my case i have array of objects. hope so its clear now
@RanaFaraz Oh, sorry. I edited the answer
can u please explain how you get to know we need to use the syntax like this ? i mean how you get to know we need to put [].address then we can get the result?
address is a property of an element in the rows array. We get the element by index (its numeric position in the array). So, rows[index], in this case, returns an object with data (id, first_name, last_name, address, etc). Therefore, we can access its properties.
we are mapping on appData then how index get to know about rows[index].address ?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.