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 .

-
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.robinood– robinood2022-06-14 12:38:37 +00:00Commented Jun 14, 2022 at 12:38
-
anyone knows PLEASE?Rana Faraz– Rana Faraz2022-06-14 12:42:57 +00:00Commented Jun 14, 2022 at 12:42
Add a comment
|
1 Answer
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.
5 Comments
Rana Faraz
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
User456
@RanaFaraz Oh, sorry. I edited the answer
Rana Faraz
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?
User456
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.Rana Faraz
we are mapping on appData then how index get to know about rows[index].address ?