I have the following component that is called from a container component. The container component passes the transaction prop.
I know that the data property in prop is passed in order and has data and can be accessed from a console.log call. However, when I try to display the data and create a list, I get an error message:Cannot read property 'map' of undefined
Here's what the data looks like:
[
{"transid":3426,"acct":"acct1","category":"Auto"},
{"transid":3427,"acct":"acct2","category":"Subscriptions"}
]
What am I doing wrong?
import React from 'react';
export default function TransactionManagerView (props) {
console.log(props.data);
return (
<ul>
{
props.data.map(function(el,index) {
return <li key={index}>{el.category}</li>
})
}
</ul>
)
}
source
share