-1
Hello, I have two arrays of objects within an array of objects, and I would like to be able to access them and render the objects from within (the objects of the object obj1
and of obj2
)
Well, I thought of these arrays as a way to manipulate two variables (obj1
and obj2
) with their respective values to render them using a map, however the way I did does not work, I would like to know how to do this the right way and also would like to know if there is an easier and simpler way to organize all these object arrays (good practices of code).
const teste = [
{
obj1: [
{
teste: "teste",
teste2: "teste2",
},
],
},
{
obj2: [
{
teste: "teste",
teste2: "teste2",
},
],
},
];
console.log(teste.map((e) => e.map((x) => x.obj1)));
From now on Thank you !
But the question is how to go through this structure with
for
? or is what specifically ? What are you trying to do with these arrays ?– Isac
Isac then, I had thought of using a map because the idea is this, I have two components (in React) that will appear together on the screen and both have fixed data (e.g., title, image description) and instead of passing these props to these components when calling the component (ex <Card title="title />) I would put all this information in these arrays and could render it to nois components using a map would look something like this test.map(((e) => { <Card title={e.title} /> }) understood ?
– Pedro