最近我发现如果我将 map 函数应用到 Meteor 的 Tracker.autorun 函数中的数组,它就不起作用,我一直想知道为什么?我尝试制作静态数组,即使那不起作用。
renderMyBooks() {
Tracker.autorun(() => {
Meteor.subscribe("ziglerNata")
console.log(Meteor.userId());
const myBooks = BooksInfo.find({ userId: Meteor.userId() }).fetch();
//const myBooks = [1,2,3,4,5];
console.log(myBooks);
return (myBooks.map(book => {
return (
<div key={book._id} className="book-info">
<div className="book-info-content">
<div className="book-info-content-t-a">
<h3>{book.title} </h3>
<h5>{book.author}</h5>
</div>
</div>
</div>
)
})
)
})
}