I’ve read a couple of Stack overflow posts, but nothing that applies to the data layer in Meteor.
I made a mistake by nesting some data and now I’m struggling to find the light. Please help me understand what is going on.
{ _id: 1, ownerId: 03dk08xk30j, .... path: [ {id: 1, name: 'filename.jpg', path: 'http://www.meteor.com/logo.png", path: '/home/user/documents/uploads/filename.jpg"}, {id: 2, name: 'filename2.jpg', url: 'http://www.meteor.com/logo2.png", path: '/home/user/documents/uploads/filename2.jpg"} ]
}
I have a renderAttachments() function that I want to return all of the name/path/url data fields.
renderAttachments() {
return this.data.res.path.map((value) => {
return <Attachment key={value._id} value={value} />;
});
},
I give it a prop
Attachment = React.createClass({
render() {
return (
<div>{this.props.value.name}</div>
)
}
});
React returns complaining that this.data.res.path is undefined. So, I guess the data isn’t ready? Or I need the correct path?
I can pull out the path if I use JSON notation in the Attachment component. And use this.data.res… instead of this.data.res.path.map…but that’s not an option!
Please help!