Currently, I am delving into a project involving React, Redux, and JS. The tutorial I am following incorporates a dummy object within the redux store as illustrated below.
const initState = {
posts:[
[
{id: '1', title: 'Fire', body: 'Squirtle Laid an Egg'},
{id: '2', title: 'Land', body: 'Charmander Laid an Eg'},
{id: '3', title: 'More Land', body: 'a Helix Fossil was Found'}
]
]
}
During my learning process, I noticed that the producer of the tutorial leverages posts.map() to extract data from the object. However, I am curious if there is a way to retrieve this data without utilizing the map function. I attempted the following:
<p>{posts[0].id}</p>
Unfortunately, this triggered an error message:
Uncaught TypeError: Cannot read property '0' of undefined
Could someone guide me on the correct way to access only the first id value of this object?