【发布时间】:2018-05-23 20:09:26
【问题描述】:
ContactList.js
var React = require('react');
var Contact = require('./contact.js');
var ContactList = React.createClass({
render: function() {
return(
<div>
<h3>Contacts</h3>
<table className="table table-striped">
<thead>
<tr>
<th>Name</th>
<th>Number</th>
<th>Email</th>
<th></th>
</tr>
</thead>
<tbody>
{
this.props.contacts.map(function(contact, index) {
<Contact contact={contact} key={index} />
})
}
</tbody>
</table>
</div>
)
}
Contact.js
var React = require('react');
var Contact = React.createClass({
render: function() {
return(
<tr>
<td>{this.props.contact.name}</td>
<td>{this.props.contact.phone}</td>
<td>{this.props.contact.email}</td>
</tr>
)
}
})
module.exports = Contact;
基本上,我可以在控制台中从 firebase 获取联系人数据,但我想显示我保存在表格中的所有联系人。在幕后,有 react-flux 设置。状态“联系人”基本上是数组内的一个对象,当我去反应工具时,我看不到联系人组件,如果我尝试console.log 验证联系人组件中没有任何工作,似乎道具是不传递给联系人组件,有时我也会得到
[Deprecation] Synchronous XMLHttpRequest on the main thread is deprecated because of its detrimental effects to the end user's experience.不知道是不是这个原因。
有人可以解释一下怎么回事吗?提前致谢!!。
【问题讨论】:
-
你需要
returnmap函数内的组件 -
该死的!!!!我怎么忘记了,谢谢:P
标签: javascript reactjs