I am new to react and I am having trouble finding a way to map an array within an array to display the username and id in the component. How can I achieve this? Is this a wrong approach?
[Array(4)]
0: Array(4)
0: {user: "testuser1", id: "2"}
1: {user: "testuser2", id: "3"}
2: {user: "testuser3", id: "4"}
3: {user: "testuser4", id: "5"}
length: 4
__proto__: Array(0)
length: 1
__proto__: Array(0)
Thanks
userinfois the state which holds this array.userinfo.0throws an error.arr.map(inner => inner.map(obj => <p key={obj.id}>{obj.user}</p>));. To access an element in an array, you could useuserInfo[0], but it's unclear whether your (outer) array can have more than one nested array. Using two maps will take care of both cases (0 or more nested arrays)