I have the following component which is being called from a container component. The container component passes the transactions prop.
I know that the data property in prop is being passed in fine and has data and can be accessed from the console.log call. However, when I try to map the data and create the list, I get an error: Cannot read property 'map' of undefined
Here is 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>
)
}
Question&Answers:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…